Jump to content

Set X of Physics Group


hby2000
 Share

Recommended Posts

I am confused because Groups don't work in Phaser as I would expect them to. How do I move all objects at once while keeping their relative distance to another? All transform methods seem to work on a for-each-basis but I want to transform the group as I would transform a single object.
 

platforms = game.add.physicsGroup();
platforms.create(100, 150, 'platform');
platforms.create(300, 300, 'platform');
platforms.create(500, 450, 'platform');

//I want to keep the group's layout, so this doesn't work
platforms.setX(-100);

//this does nothing
platforms.x = -100

 

Link to comment
Share on other sites

Whoops, no this doesn't really help. I want to move the group to the last pointer X position, so I'm dealing in absolute values, not relatives. I tried

incX(pointer.x - pointer.prevPosition.x)

and it does somehow what I want. But it also gives unexpected results. I would've tried to wrap everything in a container but it doesn't take groups as children. Is this really such an exotic use case? Moving a group as a whole?

Edited by hby2000
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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