Jump to content

Walking animation


Batzi
 Share

Recommended Posts

Hello, I am new to Phaser and I am still learning how to move sprites on the screen among other things.

 

I have this walking animation set: http://i.stack.imgur.com/pGGbv.png

 

I'd like to move my character anywhere on the screen by using the arrow keys (up,down,left and right).

 

Now I know how to execute something when an arrow key is down but my question is related to the PNG file that I am loading.

 

1) Do I load it as a spritesheet?

2) Do I use the "animations.add"?

3) How do I separate the frames in the PNG to correspond to specific arrow keys?

 

ex: If I press down, I want to use the first row of that PNG and make use of every frame to animate the character's movement.

 

I also need to move that character on the screen with every frame used so I assume character.body.velocity.x/y should be used in this case. 

Link to comment
Share on other sites

i think the best thing to do is go through these examples first

http://phaser.io/examples/v2/category/animation

 

this one seems to match what you need to some extent

http://phaser.io/examples/v2/animation/two-frame-test

 

these examples are based on frames that are all equally sized

Thank you. The second link is very helpful. I will see what I can do :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...