0
\$\begingroup\$

I'm developing a HTML5 Phaser game. In this game I do have a Group which I would like to behavior as a physics body (arcade-physics).

It is a character with a lot of moving parts (sprites) inside this group. In this case the group acts like a container for the sprites.

However I only able do add physics behavior to a sprite.

game.physics.arcade.enable(mySprite); // works good!

Doing the same to a group does not works. it only add physics to children sprites

game.physics.arcade.enable(myroup) // does no works
myGroup.body.(...)  // body is undefined

I would like to create a "virtual" body to this group, mannually set dimensions for it (body.setSize) and add all my sprites inside it. Is that possible in any another way?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

I think you can't do it.

Phaser groups doesn't have body: http://phaser.io/docs/2.4.4/Phaser.Group

But you can use setAll method to set properties to all sprites of a group: http://phaser.io/docs/2.4.4/Phaser.Group.html#setAll

Otherwise, if you want more complex objects you could try another type of physics (P2) and make complex bodies with polygons.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .