Jump to content

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


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

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.

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.


  • Recently Browsing   0 members

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