Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Animated sprites in array


kvazmatik
 Share

Recommended Posts

Hello,

I have problem with animated sprites in array playing animation.

for (r = 0; r < 6; r++)
{
   monster = this.add.sprite( r * x, r * y, 'monster');
   monster.setDepth(2);
   monster.setVisible(false);

   monster.on('animationcomplete', function (sprite)
   {
      if (sprite.key === 'monster_create') 
      {
         monster.play('monster_wait');
      }
      else if (sprite.key === 'monster_wait') 
      {
         monster.play('monster_smash');
      }
   }, this);

   monsters[r] = monster;
}

then when I play for example

monsters[0-4].play('monster_create');

The last indexed animated sprite (in this case [5]) is being played, NOT the one I played.

Any help will be welcome :)

Using phaser 3.6.0

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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