flo71099 Posted March 18, 2015 Share Posted March 18, 2015 Hi everyone, I've got a problem about P2 body. I've got a group who contains sprites with body enabled./*...*/this.game.physics.startSystem(Phaser.Physics.P2JS);/*...*/this.myGroup = new Phaser.Group(this.game);item = new Phaser.Sprite(this.game, x, y, 50, 'sprite');this.game.physics.p2.enable(item, true);this.myGroup.add(item);When I move the group like bellowthis.myGroup.x = 100;this.myGroup.y = 100;Sprite move the right way, but not his body ! .. and that is my problem :/ what is the right way to make the body following the sprite ? Link to comment Share on other sites More sharing options...
ZoomBox Posted March 19, 2015 Share Posted March 19, 2015 You should use myGroup.setProperty(...) as it's explained here http://docs.phaser.io/Phaser.Group.html#setProperty Note that we rarely set a X and Y value on a sprite with a physic body. We often use velocity.x/.y or acceleration. Link to comment Share on other sites More sharing options...
Nikow Posted March 19, 2015 Share Posted March 19, 2015 If u try this :this.myGroup.body.x = 100;this.myGroup.body.y = 100; Link to comment Share on other sites More sharing options...
flo71099 Posted March 19, 2015 Author Share Posted March 19, 2015 ZoomBox, this wouldn't work, or at least not the way I expected.I've got many items in my group, I want their positions to be relative to the group. there is no way to "add" sprite.body to a group ? Nikow, a Group doesn't have a body, this wouldn't work too. To be clearer about what I'm trying to do, I've a group containing items, I want my world size to be group size + 1000 and then position my group to the center of the world.So, everything work well except the bodies which don't seems to be attach to the group. Link to comment Share on other sites More sharing options...
Westinghouse Posted March 19, 2015 Share Posted March 19, 2015 That won't work. Rich mentioned it here https://github.com/photonstorm/phaser/issues/1065 . You have to move each of your sprites separately. flo71099 1 Link to comment Share on other sites More sharing options...
flo71099 Posted March 19, 2015 Author Share Posted March 19, 2015 Thanks Westinghouse, that is what I wanted to know !! (even if it doesn't make me happy :/) Link to comment Share on other sites More sharing options...
Recommended Posts