Showing posts with label codeExample. Show all posts
Showing posts with label codeExample. Show all posts

Thursday, January 12, 2012

.getBounds "wrong" results.

When getting bounds of an object relative to it's OWN coordinate system,
those values will NOT be scaled. I was trying to figure out why my bounding
boxes were off with the explosions in my game. I realized it was because
I created the explosions by scaling the objects in the game, which made
the results of .getBounds unreliable.

Solution:
var oBnd:Rectangle = someObject.getBounds(someObject);
var bLft:Number = oBnd.left   * someObject.scaleX;
var bRgt:Number = oBnd.right  * someObject.scaleX;
var bTop:Number = oBnd.top    * someObject.scaleY;
var bBot:Number = oBnd.bottom * someObject.scaleY;
//Now use bLft,bRgt,bTop & bBot to make your calculations.

3HRS30MIN. Time For Bed.
Sleep on why my collision checking is not working when trying to go from bounding box collision to circle-circle collision.