瀏覽代碼

setting x/y will keep constant width/height

ncannasse 10 年之前
父節點
當前提交
444082a05f
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      h2d/col/Bounds.hx

+ 6 - 4
h2d/col/Bounds.hx

@@ -49,8 +49,8 @@ class Bounds {
 	}
 
 	public inline function set(x, y, width, height) {
-		this.x = x;
-		this.y = y;
+		this.xMin = x;
+		this.yMin = y;
 		this.xMax = x + width;
 		this.yMax = y + height;
 	}
@@ -186,11 +186,13 @@ class Bounds {
 		return yMin;
 	}
 
-	inline function set_x(x) {
+	inline function set_x(x:Float) {
+		xMax += x - xMin;
 		return xMin = x;
 	}
 
-	inline function set_y(y) {
+	inline function set_y(y:Float) {
+		yMax += y - yMin;
 		return yMin = y;
 	}