1. Eugene Veretennikov
  2. spinehx

Commits

nitrobin  committed e8a2004

js positioning fix

  • Participants
  • Parent commits 96691a2
  • Branches default

Comments (0)

Files changed (4)

File src-test/spinehx/AnimationStateTest.hx

View file
  • Ignore whitespace
 
     public function new() {
         super();
+        lastTime = haxe.Timer.stamp();
 
         atlas = TextureAtlas.create(Assets.getText("assets/spineboy.atlas"), "assets/", new BitmapDataTextureLoader());
         var json = SkeletonJson.create(atlas);

File src-test/spinehx/MixTest.hx

View file
  • Ignore whitespace
 
     public function new() {
         super();
+
+        lastTime = haxe.Timer.stamp();
 		var name = "spineboy";
 
 		var atlas:TextureAtlas = TextureAtlas.create(Assets.getText("assets/" + name + ".atlas"), "assets/", new BitmapDataTextureLoader());

File src-test/spinehx/SkeletonTest.hx

View file
  • Ignore whitespace
 
     public function new() {
         super();
+
+        lastTime = haxe.Timer.stamp();
         name = "goblins"; // "spineboy";
 
         var atlas:TextureAtlas = TextureAtlas.create(Assets.getText("assets/" + name + ".atlas"), "assets/", new BitmapDataTextureLoader());
         }
     }
 
+//    private static inline function log(s){
+//       untyped __js__("console.log(s);");
+//    }
 
     public function render(e:Event):Void {
         var deltaTime:Float = haxe.Timer.stamp() - lastTime;
 		time += deltaTime;
 
 		var x:Float = skeleton.getX() + 160 * deltaTime * (skeleton.getFlipX() ? -1 : 1);
-		if (x > stage.stageWidth) skeleton.setFlipX(true);
-		if (x < 0) skeleton.setFlipX(false);
+		if (x > stage.stageWidth) {
+            x = stage.stageWidth;
+            skeleton.setFlipX(true);
+        }
+		if (x < 0) {
+            x = 0;
+            skeleton.setFlipX(false);
+        }
         skeleton.setX(x);
 
 		animation.apply(skeleton, time, true);

File src/spinehx/platform/nme/renderers/SkeletonRenderer.hx

View file
  • Ignore whitespace
 		var flipX:Int = (skeleton.flipX) ? -1 : 1;
 		var flipY:Int = (skeleton.flipY) ? 1 : -1;
 		var flip:Int = flipX * flipY;
+        var skeletonX:Float = skeleton.getX();
+        var skeletonY:Float = skeleton.getY();
 		for (slot in drawOrder) {
 			var attachment:Attachment = slot.attachment;
 			if (Std.is(attachment, RegionAttachment)) {
                 var bone:Bone = slot.getBone();
                 var x:Float = regionAttachment.x - region.offsetX;
                 var y:Float = regionAttachment.y - region.offsetY;
-                wrapper.x = bone.worldX + x * bone.m00 + y * bone.m01;
-                wrapper.y = bone.worldY + x * bone.m10 + y * bone.m11;
+                wrapper.x = skeletonX + bone.worldX + x * bone.m00 + y * bone.m01;
+                wrapper.y = skeletonY + bone.worldY + x * bone.m10 + y * bone.m11;
                 wrapper.rotation = -(bone.worldRotation + regionAttachment.rotation) * flip;
                 wrapper.scaleX = (bone.worldScaleX + regionAttachment.scaleX - 1) * flipX;
                 wrapper.scaleY = (bone.worldScaleY + regionAttachment.scaleY - 1) * flipY;