eddieone Posted May 27, 2016 Share Posted May 27, 2016 I think groups are not really possible with Box2D based on a post by Rich some where. Instead, I have made some text follow the player by setting it's x and y relative to the player's positions. It's look alright but has a floating appearance like the body moves away faster some of the time. Is there a way to get multiple sprite attached to a body without any floating? Link to comment Share on other sites More sharing options...
Tom Atom Posted May 28, 2016 Share Posted May 28, 2016 Hi, just use addChild on sprite. Added child sprite will not have body, but will move along with parent. Look at image below - for test I added explosion as child to ball (with 50, 50 offset). As debug draw is on, you can see, that ball has body, while attached explosion not. If you need more complex collision shape, solve it through adding more fixtures to body. eddieone 1 Link to comment Share on other sites More sharing options...
eddieone Posted May 30, 2016 Author Share Posted May 30, 2016 Ok thanks I will try that Link to comment Share on other sites More sharing options...
eddieone Posted June 7, 2016 Author Share Posted June 7, 2016 It worked like a charm, except the text had to be flipped when the character switches directions. Link to comment Share on other sites More sharing options...
Tom Atom Posted June 10, 2016 Share Posted June 10, 2016 You can create empty sprite (no graphical representation) with physical body of your need - as top of your hierarchy. Then you can add 2 children - one for your panda sprite, second for text. With this you will not need to flip text when sprite is flipped. Link to comment Share on other sites More sharing options...
eddieone Posted June 10, 2016 Author Share Posted June 10, 2016 Ah, good idea. I already used a blank sprite to get sprites behind my main character. So I just need to give the title it's own layer and make sure to only flip the character sprite. Thanks Tom! Link to comment Share on other sites More sharing options...
Recommended Posts