Billy Back Bedroom
Billy Back Bedroom

Reputation: 592

Finding an original rectangle's dimensions from rotation and bounding box dimensions

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(...)?

Upvotes: 0

Views: 800

Answers (2)

sberry
sberry

Reputation: 131968

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.

Upvotes: 1

antpaw
antpaw

Reputation: 15985

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

Upvotes: 1

Related Questions