Browse Source

Better getBounds.

NathanSweet 12 years ago
parent
commit
b882cecc16
1 changed files with 10 additions and 1 deletions
  1. 10 1
      spine-starling/spine-starling/src/spine/SkeletonSprite.as

+ 10 - 1
spine-starling/spine-starling/src/spine/SkeletonSprite.as

@@ -8,6 +8,7 @@ import spine.attachments.RegionAttachment;
 import starling.animation.IAnimatable;
 import starling.animation.IAnimatable;
 import starling.core.RenderSupport;
 import starling.core.RenderSupport;
 import starling.display.DisplayObject;
 import starling.display.DisplayObject;
+import starling.utils.MatrixUtil;
 
 
 public class SkeletonSprite extends DisplayObject implements IAnimatable {
 public class SkeletonSprite extends DisplayObject implements IAnimatable {
 	static private var tempPoint:Point = new Point();
 	static private var tempPoint:Point = new Point();
@@ -167,7 +168,15 @@ public class SkeletonSprite extends DisplayObject implements IAnimatable {
 	override public function getBounds (targetSpace:DisplayObject, resultRect:Rectangle = null) : Rectangle {
 	override public function getBounds (targetSpace:DisplayObject, resultRect:Rectangle = null) : Rectangle {
 		if (!resultRect)
 		if (!resultRect)
 			resultRect = new Rectangle();
 			resultRect = new Rectangle();
-		resultRect.setTo(0, 0, 0, 0);
+		if (targetSpace == this)
+			resultRect.setTo(0, 0, 0, 0);
+		else if (targetSpace == parent)
+			resultRect.setTo(x, y, 0, 0);
+		else {
+			getTransformationMatrix(targetSpace, tempMatrix);
+			MatrixUtil.transformCoords(tempMatrix, 0, 0, tempPoint);
+			resultRect.setTo(tempPoint.x, tempPoint.y, 0, 0);
+		}
 		return resultRect;
 		return resultRect;
 	}
 	}