Jump to content

Problem with Sprite


SteveMavic
 Share

Recommended Posts

Hello.
I have a problem with sprite. Phaser don't see the last two animations (the animations of jump).
vGSsWTA.png

I want to do a second "layer" of animations, but I don't want to make a very, very long picture, btw :)

How can I solve this?

Link to comment
Share on other sites

There are two problems you have to solve with spritesheet:

  • load all frames - you have 12 frames. Load your spritesheet like: game.load.spritesheet(key, url, width_of_frame, height_of_frame, number_of_frames_total) ... number_of_frames_total  = 12 in your case. Refer to this example: http://phaser.io/examples/v2/animation/sprite-sheet (mummy frames are not all in one row),
  • create your animations - "walk", "jump" in your case, like this: this.animations.add("walk", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); and this.animations.add("jump", [11, 12]); ... simply refer to frame indices.

Then you can play anims like: sprite.animation.play(anim_name) ... anim_name = "walk" / ""jump"

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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