Jump to content

Group accelerateToObject?


ylluminarious
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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