{"id":8425,"date":"2013-02-12T10:00:33","date_gmt":"2013-02-12T08:00:33","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=8425"},"modified":"2013-02-12T11:12:58","modified_gmt":"2013-02-12T09:12:58","slug":"android-game-development-with-libgdx-animation-part-2","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html","title":{"rendered":"Android Game Development with libgdx \u2013 Animation, Part 2"},"content":{"rendered":"<p>This is the second part of the Building a Game with LibGdx series. Make sure you read the <a href=\"http:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html\">first part<\/a> before starting on the second. There will be a lot of stuff covered in the following articles so I will try to break them down in more digestible sizes. We left off with a basic world and Bob gliding back on forth when using the arrow keys or touching the screen. Let\u2019s add some realism to the movement and animate the character whenever it is moving.<\/p>\n<h2>Character Animation<\/h2>\n<p>To animate Bob, we will use the simplest technique called <a onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','code.google.com']);\" href=\"http:\/\/code.google.com\/p\/libgdx\/wiki\/SpriteAnimation\">sprite animation<\/a>. The animation is nothing more than a sequence of images shown at a set interval to create<br \/>\n&nbsp;<br \/>\nthe illusion of movement. The following sequence of images is used to create the running animation. <\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/running-bob.png\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/running-bob.png\" alt=\"bob running sprite sheet\" width=\"116\" height=\"50\" \/><\/a><\/p>\n<p>. I have used Gimp to create the running character by playing <a onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','vacuumflowers.com']);\" href=\"http:\/\/vacuumflowers.com\/star_guard\/\" target=\"_blank\">Star Guard<\/a> a lot and analysing its running sequence. To create animations is quite simple. We want to display each frame for a certain amount of time and then switch to the next image. When we reached the end of the sequence we start again. This is called <strong>looping<\/strong>. We need to determine the <strong>frame duration<\/strong> which the amount of time the frame will be displayed for. Let\u2019s say we are rendering the game at 60 FPS, meaning we render a frame every 1 \/ 60 = 0.016 s. We have just 5 frames to animate a full step. Considering a typical athlete\u2019s <a onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','en.wikipedia.org']);\" href=\"http:\/\/en.wikipedia.org\/wiki\/Cadence_(gait)\" target=\"_blank\">cadence<\/a> of 180, we can work out how much time we show each frame to make the running realistic.<\/p>\n<h2>The math of running<\/h2>\n<p>A cadence of 180 means 180 steps per minute. To calculate the number of steps per second we have 180 \/ 60 = 3. So every second we have need to take 3 steps. Our 5 frames make up one full step so we need to show 3 * 5 = 15 frames every second to simulate a professional athlete\u2019s running. This is not sprinting by the way. Our frame duration will be 1 \/ 15 = 0.066 second. That is 66 ms.<\/p>\n<h2>Optimising the images<\/h2>\n<p>Before we add it to the game, we will optimise the images. Currently the project has the images as separate png files under the <code>assets\/images<\/code> directory in the <code>star-assault-android<\/code> project. We are currently using <code>block.png<\/code> and <code>bob_01.png<\/code>. There are a few more images, namely <code>bob_02 - 06.png<\/code>. These images make up the animation sequence. Because libgdx is using OpenGL under the hood, it\u2019s not optimal to give the framework lots of images as textures to work with. What we will do, is to create a so called <code>Texture Atlas<\/code>. A texture atlas is just an image which is big enough to fit all the images on it and it has a descriptor holding each individual image\u2019s name, position in the atlas and size. The individual images are called <strong>regions<\/strong> in the atlas. It there are many images, the atlas can have multiple <strong>pages<\/strong>. Each page gets loaded into the memory as a singe image and the regions are used as individual images. Don\u2019t need to know all this but this makes the application more optimal, will load more quickly and will run more smoothly. Libgdx has a utility called <a onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','github.com']);\" href=\"https:\/\/github.com\/libgdx\/libgdx\/blob\/master\/extensions\/gdx-tools\/src\/com\/badlogic\/gdx\/tools\/imagepacker\/TexturePacker2.java\" target=\"_blank\">TexturePacker2<\/a> to create these atlases. It can be run from the command line or used programatically. To run it from Java use the following program:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">package net.obviam.starassault.utils;\r\n\r\nimport com.badlogic.gdx.tools.imagepacker.TexturePacker2;\r\n\r\npublic class TextureSetup {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tTexturePacker2.process('\/path-to-star-guard-assets-images\/', 'path-to-star-guard-assets-images', 'textures.pack');\r\n\t}\r\n}<\/pre>\n<p>Make sure that you add <code>gdx-tools.jar<\/code> to your <code>libs<\/code> directory. Change the attributes of the <code>process<\/code> method to point to the directory where the assets are located.<\/p>\n<h4>Note:<\/h4>\n<p> Also rename the files that contain the underscore \u201c_\u201d character because the TexturePacker2 uses it as a delimiter and we currently don\u2019t need that. Replace the underscore character with the hyphen \u201c-\u201d character. Processing the images in our directory should produce 2 files: <code>textures.png<\/code> and <code>textures.pack<\/code>. The texture atlas should look similar to the following image <\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/textures.png\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/textures.png\" alt=\"texture atlas\" width=\"128\" height=\"64\" \/><\/a><\/p>\n<p style=\"text-align: center;\">The directory structure I am using is the following: <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/Screen-Shot-2013-02-11-at-13.33.22.png\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/02\/Screen-Shot-2013-02-11-at-13.33.22.png\" alt=\"Assets Directory Structure\" width=\"204\" height=\"210\" \/><\/a><\/p>\n<p>Now that we have worked out what our animation will be, the frame duration and optimised the assets, let\u2019s add it to the game. We will modify <code>Bob.java<\/code> first as this is the smallest bit<\/p>\n<pre class=\" brush:java\">public class Bob {\r\n\r\n\t\/\/ ... omitted ... \/\/\r\n\r\n\tfloat\t\tstateTime = 0;\r\n\r\n\t\/\/ ... omitted ... \/\/\r\n\r\n\tpublic void update(float delta) {\r\n\t\tstateTime += delta;\r\n\t\tposition.add(velocity.tmp().mul(delta)); \r\n\t}\r\n}<\/pre>\n<p>We added an attribute called <code>stateTime<\/code>. This will track Bob\u2019s time in a particular state. We will be using it to provide the time spent by Bob in the game. It is important for the animation to work out which frame to show. Don\u2019t worry about it now. If you really want to understand, think of each frame of the animation as a state. Bob goes through state_frame_1, state_frame_2 and so on. Each one of these states lasts for 0.066 seconds. Once the state time exceeded 0.066 seconds, Bob goes into the next state. The animation class knows which image to provide to be displayed for the current state. It is also called the <strong>key frame<\/strong>. The <code>WorldRenderer.java<\/code> suffers the most changes. The following snippet contains all the changes.<\/p>\n<pre class=\" brush:java\">public class WorldRenderer {\r\n\r\n\t\/\/ ... omitted ... \/\/\r\n\r\n\tprivate static final float RUNNING_FRAME_DURATION = 0.06f;\r\n\r\n\t\/** Textures **\/\r\n\tprivate TextureRegion bobIdleLeft;\r\n\tprivate TextureRegion bobIdleRight;\r\n\tprivate TextureRegion blockTexture;\r\n\tprivate TextureRegion bobFrame;\r\n\r\n\t\/** Animations **\/\r\n\tprivate Animation walkLeftAnimation;\r\n\tprivate Animation walkRightAnimation;\r\n\r\n\t\/\/ ... omitted ... \/\/\r\n\r\n\tprivate void loadTextures() {\r\n\t\tTextureAtlas atlas = new TextureAtlas(Gdx.files.internal('images\/textures\/textures.pack'));\r\n\t\tbobIdleLeft = atlas.findRegion('bob-01');\r\n\t\tbobIdleRight = new TextureRegion(bobIdleLeft);\r\n\t\tbobIdleRight.flip(true, false);\r\n\t\tblockTexture = atlas.findRegion('block');\r\n\t\tTextureRegion[] walkLeftFrames = new TextureRegion[5];\r\n\t\tfor (int i = 0; i &lt; 5; i++) {\r\n\t\t\twalkLeftFrames[i] = atlas.findRegion('bob-0' + (i + 2));\r\n\t\t}\r\n\t\twalkLeftAnimation = new Animation(RUNNING_FRAME_DURATION, walkLeftFrames);\r\n\r\n\t\tTextureRegion[] walkRightFrames = new TextureRegion[5];\r\n\r\n\t\tfor (int i = 0; i &lt; 5; i++) {\r\n\t\t\twalkRightFrames[i] = new TextureRegion(walkLeftFrames[i]);\r\n\t\t\twalkRightFrames[i].flip(true, false);\r\n\t\t}\r\n\t\twalkRightAnimation = new Animation(RUNNING_FRAME_DURATION, walkRightFrames);\r\n\t}\r\n\r\n\tprivate void drawBob() {\r\n\t\tBob bob = world.getBob();\r\n\t\tbobFrame = bob.isFacingLeft() ? bobIdleLeft : bobIdleRight;\r\n\t\tif(bob.getState().equals(State.WALKING)) {\r\n\t\t\tbobFrame = bob.isFacingLeft() ? walkLeftAnimation.getKeyFrame(bob.getStateTime(), true) : walkRightAnimation.getKeyFrame(bob.getStateTime(), true);\r\n\t\t}\r\n\t\tspriteBatch.draw(bobFrame, bob.getPosition().x * ppuX, bob.getPosition().y * ppuY, Bob.SIZE * ppuX, Bob.SIZE * ppuY);\r\n\t}\r\n\t\/\/ ... omitted ... \/\/\r\n}<\/pre>\n<p><strong>#05<\/strong> \u2013 declaring the RUNNING_FRAME_DURATION constant which controls how long a frame in the running\/walking cycle will be displayed<br \/>\n<strong>#08 \u2013 #11<\/strong> \u2013 <code>TextureRegion<\/code>s for Bob\u2019s different states. <code>bobFrame<\/code> \u2013 will hold the region that will be displayed in the current cycle.<br \/>\n<strong>#14 \u2013 #15<\/strong> \u2013 the two <code>Animation<\/code> objects that are used to animate Bob when walking\/running.<\/p>\n<p><strong>Loading the images from a <code>TextureAtlas<\/code><\/strong><\/p>\n<p><strong>#19<\/strong> \u2013 the new <code>loadTextures()<\/code> method<br \/>\n<strong>#20<\/strong> \u2013 loading the TextureAtlas form the internal file. This is the <code>.pack<\/code> file resulted from <code>TexturePacker2<\/code>.<br \/>\n<strong>#21<\/strong> \u2013 assigning the region named \u201cbob-01? (this is the actual png name without extension \u2013 see TexturePacker2) to the <code>bobIdleLeft<\/code> variable.<br \/>\n<strong>#22 \u2013 #23<\/strong> \u2013 creating a new <code>TextureRegion<\/code> (note the use of copy constructor, we need a copy, not a reference) and flipping it on the X axis so we have the same image but mirrored for Bob\u2019s idle state but when facing right. The flipping is very useful as we don\u2019t need to load an extra image, we create one from an existing one.<br \/>\n<strong>#24<\/strong> \u2013 assign the corresponding region to the block<br \/>\n<strong>#25 \u2013 #28<\/strong> \u2013 we create an array of <code>TextureRegion<\/code>s that will make up the animation. We know that there are 5 frames and their names: <code>bob-02, bob-03, bob-04, bob-05<\/code> and <code>bob-06<\/code>. We use a for loop for convenience.<br \/>\n<strong>#29<\/strong> \u2013 This is where the animation for the walking left state is defined. The first parameter is the duration of each frame from the sequence expressed in seconds (0.06) and the second parameter takes the ordered list of frames making up the animation.<br \/>\n<strong>#31 \u2013 #38<\/strong> \u2013 Creating the animation for the walking right state. It is a copy of the animation for the walking left state but each frame is flipped. It is important to make a copy of the frames and not flipping them as the originals get flipped too.<br \/>\n<strong>#40<\/strong> \u2013 the changed <code>drawBob()<\/code> method.<br \/>\n<strong>#42<\/strong> \u2013 setting the active frame to one of the idle frames depending on Bob\u2019s facing<br \/>\n<strong>#44<\/strong> \u2013 in case Bob is in a walking state, we extract the corresponding frame for one of the walking sequences based on Bob\u2019s current state time and assign it to bobFrame which will be drawn to the screen. Running the <code>StarAssaultDesktop<\/code> application, we should see the Bob animation in action. It should look something like this:<\/p>\n<p><iframe src=\"http:\/\/www.youtube.com\/embed\/xhACjRWiBMQ\" frameborder=\"0\" width=\"420\" height=\"315\"><\/iframe><\/p>\n<p>The source code for this project can be found here: <a onclick=\"javascript:_gaq.push(['_trackEvent','outbound-article','github.com']);\" href=\"https:\/\/github.com\/obviam\/star-assault\">https:\/\/github.com\/obviam\/star-assault<\/a>. You need to checkout the branch <strong>part2<\/strong>. To check it out with git: <code>git clone -b part2 git@github.com:obviam\/star-assault.git<\/code>. You can also <a onclick=\"javascript:_gaq.push(['_trackEvent','download','github.com\/obviam\/star-assault\/archive\/part2.zip']);\" href=\"https:\/\/github.com\/obviam\/star-assault\/archive\/part2.zip\">download it as a zip file<\/a>.<br \/>\n&nbsp;<\/p>\n<p><strong><em>Reference: <\/em><\/strong><a href=\"http:\/\/obviam.net\/index.php\/getting-started-in-android-game-development-with-libgdx-tutorial-part-2-animation\/\">Android Game Development with libgdx \u2013 Animation, Part 2<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Impaler at the <a href=\"http:\/\/obviam.net\/\">Against the Grain<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of stuff covered in the following articles so I will try to break them down in more digestible sizes. We left off with a basic &hellip;<\/p>\n","protected":false},"author":27,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[723],"class_list":["post-8425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-games","tag-libgdx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Game Development with libgdx \u2013 Animation, Part 2<\/title>\n<meta name=\"description\" content=\"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Game Development with libgdx \u2013 Animation, Part 2\" \/>\n<meta property=\"og:description\" content=\"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-02-12T08:00:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-02-12T09:12:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Impaler\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Impaler\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html\"},\"author\":{\"name\":\"Impaler\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6bad1a2db4fb0129703629617c049f8c\"},\"headline\":\"Android Game Development with libgdx \u2013 Animation, Part 2\",\"datePublished\":\"2013-02-12T08:00:33+00:00\",\"dateModified\":\"2013-02-12T09:12:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html\"},\"wordCount\":1202,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"keywords\":[\"libgdx\"],\"articleSection\":[\"Android Games\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html\",\"name\":\"Android Game Development with libgdx \u2013 Animation, Part 2\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2013-02-12T08:00:33+00:00\",\"dateModified\":\"2013-02-12T09:12:58+00:00\",\"description\":\"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/02\\\/android-game-development-with-libgdx-animation-part-2.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Games\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-games\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android Game Development with libgdx \u2013 Animation, Part 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6bad1a2db4fb0129703629617c049f8c\",\"name\":\"Impaler\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"caption\":\"Impaler\"},\"sameAs\":[\"http:\\\/\\\/obviam.net\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Impaler\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Game Development with libgdx \u2013 Animation, Part 2","description":"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html","og_locale":"en_US","og_type":"article","og_title":"Android Game Development with libgdx \u2013 Animation, Part 2","og_description":"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of","og_url":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-02-12T08:00:33+00:00","article_modified_time":"2013-02-12T09:12:58+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Impaler","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Impaler","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html"},"author":{"name":"Impaler","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6bad1a2db4fb0129703629617c049f8c"},"headline":"Android Game Development with libgdx \u2013 Animation, Part 2","datePublished":"2013-02-12T08:00:33+00:00","dateModified":"2013-02-12T09:12:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html"},"wordCount":1202,"commentCount":5,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","keywords":["libgdx"],"articleSection":["Android Games"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html","url":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html","name":"Android Game Development with libgdx \u2013 Animation, Part 2","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2013-02-12T08:00:33+00:00","dateModified":"2013-02-12T09:12:58+00:00","description":"This is the second part of the Building a Game with LibGdx series. Make sure you read the first part before starting on the second. There will be a lot of","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/02\/android-game-development-with-libgdx-animation-part-2.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Games","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-games"},{"@type":"ListItem","position":4,"name":"Android Game Development with libgdx \u2013 Animation, Part 2"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6bad1a2db4fb0129703629617c049f8c","name":"Impaler","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","caption":"Impaler"},"sameAs":["http:\/\/obviam.net\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Impaler"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/8425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=8425"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/8425\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=8425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=8425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=8425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}