Jump to content

Problem with calling animations as group in phaser 2


Recommended Posts

I have one array having 3 phaser groups as follows


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:


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

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.

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.


  • Recently Browsing   0 members

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