hby2000 Posted July 22, 2020 Share Posted July 22, 2020 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 More sharing options...
Darko Posted July 22, 2020 Share Posted July 22, 2020 Hello, I guess you can use: platforms.incX(-100);: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Group.html#incX__anchor msanatan and hby2000 2 Link to comment Share on other sites More sharing options...
hby2000 Posted July 22, 2020 Author Share Posted July 22, 2020 Thanks! Somehow missed it reading the docs. Link to comment Share on other sites More sharing options...
hby2000 Posted July 22, 2020 Author Share Posted July 22, 2020 (edited) 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 July 22, 2020 by hby2000 Link to comment Share on other sites More sharing options...
hby2000 Posted July 22, 2020 Author Share Posted July 22, 2020 I found this thread and it really seems it's not possible in Phaser 3. Have to find a workaround then. msanatan 1 Link to comment Share on other sites More sharing options...
msanatan Posted July 24, 2020 Share Posted July 24, 2020 Glad you found that thread! I haven't used them myself but I figure Containers would be what you're looking for. I remember reading about them from this devlog: https://phaser.io/phaser3/devlog/120 Link to comment Share on other sites More sharing options...
Recommended Posts