Lysssss Posted February 4, 2017 Share Posted February 4, 2017 Still working on the Phaser, making your first Phaser game tutorial. I am not familiar with js so the question might be easy. I added 5 baddies as a group after the tutorial and I was trying to make it move and change direction every 1 sec. I used a Direction function to determine the direction for 1 baddie. However, I tried to put the time.event.loop function in my loop of creating baddies, only 1 baddie will move around. Others had a velocity of 0. There's my code. Link to comment Share on other sites More sharing options...
XekeDeath Posted February 5, 2017 Share Posted February 5, 2017 When you are creating your baddies, you are assigning them all to the same variable... This is overwriting which baddie it is pointing to, so when you get to your Direction function, the variable is pointing at the last one you created... I see you are creating them with the baddies group... You can look into the forEach functions that a group has to loop over the baddies and call Direction on each of them... Link to comment Share on other sites More sharing options...
Recommended Posts