ForgeableSum Posted July 26, 2015 Share Posted July 26, 2015 There, I said it. How often do you want to get a representation of one of your game images or sprites as a rectangle so you can perform stuff like intersection checks? Very often. But the rectangle should be relative to the world, amiright? That's what I don't understand about getBounds(). The x/y values of the rectangle are not relative to the world.. are they relative to the parent? what the hell is worldTransform? I have no clue. I figured it out several times before but I've since forgotten - because it's so counterintuitive, what getBounds does. The end result is that getBounds returns a rectangle with x/y not relative to the game world. I think this is pretty silly. I had to make my own function for getting/updating bounds: function getManualBounds(object) { if (object.manualBounds == undefined) { object.manualBounds = new Phaser.Rectangle(object.x - object.offsetX, object.y - object.offsetY, object.width, object.height); } else { object.manualBounds.x = object.x - object.offsetX; object.manualBounds.y = object.y - object.offsetY; } return object.manualBounds;} Is anyone else in the same boat?Why is getBounds so useless? what is "worldTransform"? Link to comment Share on other sites More sharing options...
wayfinder Posted July 26, 2015 Share Posted July 26, 2015 worldTransform is the complete transformation matrix that incorporates all angles and positions throughout the scene graph. It's global. Link to comment Share on other sites More sharing options...
Recommended Posts