karneekarnay Posted April 7, 2016 Share Posted April 7, 2016 Hi Guys, I have a Phaser Group called enemies that I have so far populated with enemy sprites. What I want to do is accessing them and change their velocity values so they can move backwards and forwards. My code is below. This is from my create(). //Create an empty enemy group we can user as a container. enemies = game.add.group(); //Enable physics on the enemies group enemies.enableBody = true; My code for the enemy is below. function enemyMovement(game, player, platforms, speed, enemies) { // Collide the player and the stars with the platforms game.physics.arcade.collide(player, enemies); game.physics.arcade.collide(enemies, platforms); // Reset the enemies velocity (movement) enemies.body.velocity.x = 150; }; Also I raised a post earlier about key events but I didn't get any responces. The question for that is below. Any ideas? Link to comment Share on other sites More sharing options...
mattstyles Posted April 7, 2016 Share Posted April 7, 2016 I replied to your key events. Regarding this one, what is you want to do? Individually set each entity within the group? I'm not a Phaser user but I'd have thought Phaser exposes a method for accessing children, just loop through that array and do what you like to each one. You might also want to apply something to the group as well, as I think you are doing currently. Link to comment Share on other sites More sharing options...
Recommended Posts