Jump to content

playing the whole animation


peteblank
 Share

Recommended Posts

Okay sorry for making another thread.

I looked up the manual and examples this time around. 

For the keyboard event I have it set to JustDown instead of isDown. 

Which means the the key is registered as being pressed just once.

The problem is that when the animation plays, it just plays one frame instead of the whole animation.

Please help, I'm close to completing my game.?

Link to comment
Share on other sites

How is your animation set up? Can you post a snippet of that code?

If you are using keyboard JustDown then it should trigger only once otherwise if you are still using isDown then you can use a

this.sprite.play('animationName', true); //where true will ignore if already playing rather than restart each time it's called
Link to comment
Share on other sites

18 hours ago, supertommy said:

Can you share what your code looks like? There could be many reasons why you are seeing this problem.

Sure in the create event I use

this.anims.create({
          key: "punch",
          frames: this.anims.generateFrameNumbers("punch", {
            start: 0,
            end: 7
          }),
          frameRate: 15,
          repeat: -1,
          
        });

and in the update event I use

else if (Phaser.Input.Keyboard.JustDown(shift))
          {
            console.log("pressed down key");
            player.setVelocityX(0);
            player.anims.play("punch");
          punching = true;
        } 

 

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

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