views:

234

answers:

2

In AS3, I have a Sprite that has a Z axis rotation applied.

How do I calculate that Sprite's dimensions (it's original size) from Sprite.rotationZ and Sprite.getRect(...)?

+1  A: 

sprite.width and sprite.height on sprite.rotationZ = 0 would give you the original size.

antpaw
Haha! Yeah that's my intermediate hack.I'd rather do it with the maths though, then I'll have learnt something universal rather than an AVM shortcut...
Ben
Seconds thoughts, it's obviously impossible! You win.
Ben
+1  A: 

antpaw's answer is best / easiest. It can also be done without ever seeing it visually if you switch the rotationZ back once you get your width and height, like so

var rotZ:Number = mySprite.rotationZ;
mySprite.rotationZ = 0;
var w:Number = mySprite.width;
var h:Number = mySprite.height;
mySprite.rotationZ = rotZ;

To do this mathematically you could look at this SO post and do the reverse.

sberry2A
The typical bounding box edge formula won't reverse because it's missing length plus missing length.I'm sure there is something that'll look a bit like it though...
Ben