Browse Source

fixed rotation in h2d : was inversed because of the y axis flip of 3D viewport (sic)

Nicolas Cannasse 11 years ago
parent
commit
067f05f6ec
4 changed files with 10 additions and 15 deletions
  1. 1 1
      h2d/Scene.hx
  2. 7 12
      h2d/Sprite.hx
  3. 1 1
      h2d/comp/ColorPicker.hx
  4. 1 1
      h2d/comp/GradientEditor.hx

+ 1 - 1
h2d/Scene.hx

@@ -366,7 +366,7 @@ class Scene extends Layers implements h3d.IDrawable {
 		// perform final rotation around center
 		if( rotation != 0 ) {
 			var cr = Math.cos(rotation);
-			var sr = Math.sin(rotation);
+			var sr = -Math.sin(rotation);
 			var tmpA = matA * cr + matB * sr;
 			var tmpB = matA * -sr + matB * cr;
 			var tmpC = matC * cr + matD * sr;

+ 7 - 12
h2d/Sprite.hx

@@ -214,7 +214,7 @@ class Sprite {
 				matD = scaleY;
 			} else {
 				cr = Math.cos(rotation);
-				sr = Math.sin(rotation);
+				sr = -Math.sin(rotation);
 				matA = scaleX * cr;
 				matB = scaleX * -sr;
 				matC = scaleY * sr;
@@ -232,7 +232,7 @@ class Sprite {
 				matD = scaleY * parent.matD;
 			} else {
 				var cr = Math.cos(rotation);
-				var sr = Math.sin(rotation);
+				var sr = -Math.sin(rotation);
 				var tmpA = scaleX * cr;
 				var tmpB = scaleX * -sr;
 				var tmpC = scaleY * sr;
@@ -264,33 +264,28 @@ class Sprite {
 	}
 
 	inline function set_x(v) {
-		x = v;
 		posChanged = true;
-		return v;
+		return x = v;
 	}
 
 	inline function set_y(v) {
-		y = v;
 		posChanged = true;
-		return v;
+		return y = v;
 	}
 	
 	inline function set_scaleX(v) {
-		scaleX = v;
 		posChanged = true;
-		return v;
+		return scaleX = v;
 	}
 	
 	inline function set_scaleY(v) {
-		scaleY = v;
 		posChanged = true;
-		return v;
+		return scaleY = v;
 	}
 	
 	inline function set_rotation(v) {
-		rotation = v;
 		posChanged = true;
-		return v;
+		return rotation = v;
 	}
 	
 	public function move( dx : Float, dy : Float ) {

+ 1 - 1
h2d/comp/ColorPicker.hx

@@ -54,7 +54,7 @@ private class Arrow extends h2d.css.Fill {
 		addPoint(-5, 4, color);
 		addPoint(0, 0, color);
 		addPoint(0, 0, color);
-		rotation = ang;
+		rotation = -ang;
 		this.x = x;
 		this.y = y;
 	}

+ 1 - 1
h2d/comp/GradientEditor.hx

@@ -39,7 +39,7 @@ private class CFlag extends h2d.css.Fill {
 	public function new (parent, x:Float, y:Float, ang = 0., color = 0xff000000, border = 0xFFaaaaaa) {
 		super(parent);
 		var fill = this;
-		fill.rotation = ang;
+		fill.rotation = -ang;
 		fill.x = x;
 		fill.y = y;
 		//bg