Jump to content

Can't play animations


Santiago
 Share

Recommended Posts

Hello, today my problem looks so stupid, but I can't find a way to solve it. I have a couple of animations that I add using:

this.player.animations.add('idle', Phaser.Animation.generateFrameNames('idle_',1,4), 6, true);
        this.player.animations.add('ataque', Phaser.Animation.generateFrameNames('ataque_',1,2), 10, true);
        this.player.animations.add('daño', Phaser.Animation.generateFrameNames('daño_',1,2), 5, true);
        this.player.animations.add('camina', Phaser.Animation.generateFrameNames('camina_',1,5), 10, true);
        this.player.animations.add('muerte', Phaser.Animation.generateFrameNames('muerte_',1,10), 5, true);

Everything's perfect, using this.animations,play('string') I can play it as well, but here's my problem:

To make my player attack I use Key.justDown, because I want it to attack once per pressing, but if I do:

if(this.Q.justDown){
   
  this.player.animations.play('ataque');

}

in this case this.Q = game.input.keyboard.addKey(Phaser.Keyboard.Q); and is the same I use to make attacks

if I use the propertie isDown it plays it, but is useless for me becasue the attack have finished and the animation still looping, even if I set to false the 4th parameter of animations.add.

Link to comment
Share on other sites

1 hour ago, samme said:

Set the loop parameter to false in any case.

Try 


this.game.debug.key(this.Q, /* … */);

 

I set the loop parameter to false and still replaying it, using isDown propertie, but with justDown (what I need), doesn't play it at all, still playing the idle (I think I didin't say this, I forgot it)

Link to comment
Share on other sites

  • 2 weeks later...
On 22/9/2017 at 11:34 AM, samid737 said:

you can try using input events as an alternative:

 

I tried but seems to do nothing, it just stop for a moment the current animation (idle), but anything else, I don't know what else to do

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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