开发者

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

开发者 https://www.devze.com 2022-12-17 21:43 出处:网络
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(...)?sprite.widt

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号