Sign in to follow this  
peteblank

playing the whole animation

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.😓

Share this post


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

Share this post


Link to post
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;
        } 

 

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.