Hello I'm doing a project. I wanted to know how to animate my character. I follow the guide in cocos wiki but I can't make it possible on my code.
My character can move and walk, I want to apply an animation when he jumps.It has a onKeyPressed
method. I don't know how to change the normal sprite to the movement spritesheet
, I have the plist
but I don't know how to load in my code.
I tried so many tutorials but I don't know how to implement them in my project.
I wrote a simple player movement and animation tutorial, you can find it here. You can also get the entire source code for this here.
However this tutorial does not use any spritesheet, I tried to keep it as simple as possible. To use spritesheets, you will need to do some modifications:
In your scene's "init()" method, you need to add a SpriteBatchNode object and add the plist file to the SpriteFrameCache singleton.
Then add the player object to the SpriteBatchNode
Then in the player class, create the animations like this:
You can create different animations and change them by:
Hope this helps.