Jump to content

Problem with calling animations as group in phaser 2


splintercell9dev
 Share

Recommended Posts

I have one array having 3 phaser groups as follows

code:1

exp_s = game.add.group() ;
      exp_s.physicsBodyType = Phaser.Physics.ARCADE ;
      exp_s.enableBody = true ;
      exp_s.scale.setTo(0.9) ;

      exp_m = game.add.group() ;
      exp_m.physicsBodyType = Phaser.Physics.ARCADE ;
      exp_m.enableBody = true ;
      exp_m.scale.setTo(0.7) ;
      
      exp_l = game.add.group() ;
      exp_l.physicsBodyType = Phaser.Physics.ARCADE ;
      exp_l.enableBody = true ;
      exp_l.scale.setTo(0.5) ;
      

      em_group.push(exp_s,exp_m,exp_l) ;

added animations as follows:

code:2

em_group.forEach((group,index)=> {
         group.callAll('animations.add','animations', `blink${index+1}`, [0,1,2], 10, true) ;
         group.callAll('animations.play', 'animations', `blink${index+1}`) ;
}) ;

now inside a loop event i'm creating meteors using :

meteor = em_group[index].create(xpos,-150,sprite_alias,0) ;

here sprite_alias is the id given to the spritesheet of meteors. But when meteors are created in game, animation is not starting.

but if i use code 2 in loop event it will start animation but so many animation calls are reducing the performance of my game. Pls help to fix this problem.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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