deleteme Posted December 9, 2015 Share Posted December 9, 2015 Is there a way to call on an enemies state when the enemy.kill(); line is run, and use it to cause eemies to respawn and have their speed increased? Quote Link to comment Share on other sites More sharing options...
deleteme Posted December 10, 2015 Author Share Posted December 10, 2015 Update: I did something a little different "function EnemyDemon() { var x = game.world.randomX; var y = game.world.randomY; demon = game.add.sprite(x, y, "demon"); demon.anchor.setTo(0.5, 0.5); game.physics.arcade.enable(demon); demon.body.allowRotation = false; demon.body.collideWorldBounds = true;} function create() {var enemiesTotal = 40; demons = []; for (var index = 0; index < enemiesTotal; index++) { demons.push(new EnemyDemon(index, game, demon)); }} function update() { demon.rotation = game.physics.arcade.moveToObject(demon, player, 200);}"and this causes a mess of sprites to appear on screen, but only one of them actually chases after my player, any idea what i should do? Quote Link to comment Share on other sites More sharing options...
SignalSin Posted December 10, 2015 Share Posted December 10, 2015 Your problem there is that in your update, you're only setting the rotation of demon, not demons. Quote Link to comment Share on other sites More sharing options...
deleteme Posted December 10, 2015 Author Share Posted December 10, 2015 Changing the line to demons still does not appear to work, i tried changing both cases of it to demons, EnemyDemon etc, but still was not able to get any results, except for the one sprite that does work was somehow flipped upside down by this? Quote Link to comment Share on other sites More sharing options...
SignalSin Posted December 10, 2015 Share Posted December 10, 2015 Sorry, I should have explained better. What I mean is that demons is your group, demon is just one object. You current code is only moving one sprite, because you're only setting the rotation for demon - not the group. You want to move the whole group, so you'll need to move each member of the demons group. I'm not able to test it out myself right now, but maybe try using the group.setAll method to set the rotation for all children in the group. A less efficient, but possible solution is to loop through each member of the group and set the rotation individually. See the documentation for more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.