ylluminarious Posted December 7, 2014 Report Share Posted December 7, 2014 Hi, I'm working with the `accelerateToObject` method, and I've run into a problem with it. I'm trying to accelerate a group to a single object, but I have not been able to find a working example of this. Essentially, what I want to do is this:monsters = game.add.group();monsters.enableBody = true;monsters.physicsBodyType = Phaser.Physics.ARCADE;...game.physics.arcade.accelerateToObject(monsters, player, ARBITRARY_ACCELERATION_AMOUNT);I tried to do this in my game, but it is not working and Phaser doesn't seem to like it. Can anyone help me to get a group to accelerate to another object, if this is even possible? Quote Link to comment Share on other sites More sharing options...
Odk Posted December 7, 2014 Report Share Posted December 7, 2014 Hi,You can try with:monsters.forEachAlive(function(monster) {game.physics.arcade.accelerateToObject(monster, this.player, ARBITRARY_ACCELERATION_AMOUNT);}, this);in update function. I don't know if it's possible to accelerate whole group but: http://docs.phaser.io/Phaser.Group.html#callAll from docs looks promising, but in the end it would probably iterate all members anyway. Quote Link to comment Share on other sites More sharing options...
ylluminarious Posted December 8, 2014 Author Report Share Posted December 8, 2014 Thank you. I tried the first solution (the `forEachAlive` method) and it seems to be working just fine. The `callAll` method did not seem to work, however, as it spit out an error. 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.