Sign in to follow this  
Batzi

Walking animation

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. 

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.