Jump to content

Animation cannot be activated with a button pression


salcapolupo
 Share

Recommended Posts

Hello,

 

I'm at work to my new platform game, and I'm in trouble about running a separate animation (different from the standard one, i.e. while running or walking) while the character is firing.

 

I am using a single spreadsheet while loading :

game.load.spritesheet('dude', 'sprites/dudeallmoves.png', 420, 300);

this is the creating phase:

    //  Our two animations, walking left and right.    player.animations.add('left', [6, 5, 4, 3, 2, 1, 0], 10, true);    player.animations.add('right', [9, 10, 11, 12, 13, 14, 15], 10, true);        // fire left/right    player.animations.add('fireleft', [22, 21, 20, 19, 18, 17, 16], 10, true);    player.animations.add('fireright', [23, 24, 25, 26, 27, 28, 29], 10, true);

so I can distinguish between directions with a single variable (direction="left", i.e).

 

Now the weird stuff: when I walk all seems ok, but not when I try to fire (this is inside the update() function):

  if ( fireButton.isDown )    {        player.animations.stop();        player.body.velocity.x = 0;                        if (direction=="left") player.animations.play('fireleft'); //this animation does not load??[...]    }

and nothing happens neither if I remove (just for test) the "direction" condition.

 

I'm using Phaser 2.2.2, the latest available in my knowledge.

 

I guess some code is wrong, can you give me some hints or impressions about?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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