Cocos2D-X Platformer tutorial Part 4 – Animation

Okay time to continue with my cocos2d-x tutorial, it has been a while but I intend to finish it.
Before I begin, it is going to be a bit different from the animations you may already know.

Why? It is because I have more control and it is cleaner this way, I think.

New Stuff

  • fields for Animate objects in GameScene.h
  • setupAnimations() – init animations
  • animate.setTarget(player_sprite) – target for my animation, meaning animate where the players position is
  • animate.setDuration(0.80f) – duration of animation
  • walkRight.startWithTarget(player_sprite) – well there was no method to reset the animation once it was over, because when its over it won’t animate anymore and I didn’t wanna create a ‘new’ object every time, for my luck this one did the trick 😀
  • I’m also checking for the animation after damping, since I move a little more even if I’m not pressing right or left


Recent Posts

Categories