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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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