osinski Posted May 17, 2016 Share Posted May 17, 2016 Hi! Could you explain why bounds are different after timeout? function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var group = game.add.group(); group.add(sprite); group.x = 200; group.y = 200; console.log(group.getBounds());///c.Rectangle {x: 0, y: 0, width: 27, height: 40, type: 22} setTimeout(()=>{console.log(group.getBounds());}, 1);///c.Rectangle {x: 200, y: 200, width: 27, height: 40, type: 22} } Link to comment Share on other sites More sharing options...
rich Posted May 17, 2016 Share Posted May 17, 2016 Because Pixi uses a deferred transform update. Your timeout allows for a render pass to have occurred, thus updating the transforms in the process. Instead of using setTimeout, just put in 'game.stage.updateTransform()', and it'll reflow all of the transforms, giving the same result. Link to comment Share on other sites More sharing options...
osinski Posted May 17, 2016 Author Share Posted May 17, 2016 Thank you, Rich! Link to comment Share on other sites More sharing options...
Recommended Posts