Batzi Posted October 1, 2015 Share Posted October 1, 2015 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 More sharing options...
bruno_ Posted October 1, 2015 Share Posted October 1, 2015 Have you seen phaser animation examples? There are samples there for the cases you are asking. Link to comment Share on other sites More sharing options...
Batzi Posted October 1, 2015 Author Share Posted October 1, 2015 Have you seen phaser animation examples? There are samples there for the cases you are asking.Is there a way I can get the size of each frame in that PNG? Link to comment Share on other sites More sharing options...
jmp909 Posted October 1, 2015 Share Posted October 1, 2015 i think the best thing to do is go through these examples firsthttp://phaser.io/examples/v2/category/animation this one seems to match what you need to some extenthttp://phaser.io/examples/v2/animation/two-frame-test these examples are based on frames that are all equally sized Link to comment Share on other sites More sharing options...
Batzi Posted October 1, 2015 Author Share Posted October 1, 2015 i think the best thing to do is go through these examples firsthttp://phaser.io/examples/v2/category/animation this one seems to match what you need to some extenthttp://phaser.io/examples/v2/animation/two-frame-test these examples are based on frames that are all equally sizedThank you. The second link is very helpful. I will see what I can do Link to comment Share on other sites More sharing options...
Recommended Posts