浏览代码

bugfix in getBoundsRec() not correctly updating absolute position if no child

ncannasse 10 年之前
父节点
当前提交
f70dcddf76
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      h2d/Sprite.hx

+ 6 - 6
h2d/Sprite.hx

@@ -35,7 +35,7 @@ class Sprite {
 	public function new( ?parent : Sprite ) {
 		matA = 1; matB = 0; matC = 0; matD = 1; absX = 0; absY = 0;
 		x = 0; y = 0; scaleX = 1; scaleY = 1; rotation = 0;
-		posChanged = false;
+		posChanged = parent != null;
 		visible = true;
 		childs = [];
 		filters = [];
@@ -58,17 +58,17 @@ class Sprite {
 	}
 
 	function getBoundsRec( relativeTo : Sprite, out : h2d.col.Bounds ) {
-		var n = childs.length;
-		if( n == 0 ) {
-			out.empty();
-			return;
-		}
 		if( posChanged ) {
 			calcAbsPos();
 			for( c in childs )
 				c.posChanged = true;
 			posChanged = false;
 		}
+		var n = childs.length;
+		if( n == 0 ) {
+			out.empty();
+			return;
+		}
 		if( n == 1 ) {
 			var c = childs[0];
 			if( c.visible ) c.getBounds(relativeTo, out) else out.empty();