METS BLOG

METS BLOG

Libgdx tutorial beginner Part 4 – Animation

I posted a lot of code in the previous two parts. So here we will look at how the animations are created and how they work.

  • Bobs texture is loaded from bob.png
  • With split we create a TextureRegion array. Split takes two parameters width and height in pixels.
  • There is also another array to create the mirrored textures, if bob is facing right by default we mirror it to make him face left.
  • Animation takes a duation and 1 or more TextureRegion parameters.

  • Bob has states that he can be in.
  • According to the state we select a previously created animation
  • While walking we want the animation to loop so we set loop the animation to true
  • Same logic goes for cube


Leave a Reply

Your email address will not be published. Required fields are marked *