Jump to content

How to make group act as one object - position, collisions, etc.


paperElectron
 Share

Recommended Posts

I have a group object with a few independent parts, The character sprite, the players name hovering above, and a status object, which will likely be more sprites and text in a sub-group.

How can I make this group act as one object? Like stopping the whole group with collideWorldBounds? Right now Im only able to stop the player sprite with body.collideWorldBounds = true, but the text just keeps on going right off the screen. There doesnt seem to be a way to set body properties on a group?

Link to comment
Share on other sites

Groups are just collections of sprites, so don't have a body. I would suggest you create a custom object that comprises of the parts of the character you need, and then in its update function you check to see the position of the main sprite (and adjust the others accordingly). There's an example for an Extended Sprite which I reckon could serve this purpose well.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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