Skip to content

Commit

Permalink
[haxe] Use physicsTranslate in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
davidetan committed Jul 25, 2024
1 parent 12f11cb commit 538c4ed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spine-haxe/example/src/CelestialCircusExample.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class CelestialCircusExample extends Scene {
skeletonSprite = new SkeletonSprite(skeletondata, animationStateData);
skeletonSprite.skeleton.updateWorldTransform(Physics.update);
var bounds = skeletonSprite.skeleton.getBounds();

skeletonSprite.scale = 0.2;
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
skeletonSprite.y = Starling.current.stage.stageHeight / 1.5;

skeletonSprite.state.setAnimationByName(0, "eyeblink-long", true);

addText("Drag Celeste to move her around");
Expand All @@ -79,8 +79,12 @@ class CelestialCircusExample extends Scene {
if (skeletonTouch != null) {
if (skeletonTouch.phase == TouchPhase.MOVED) {
skeletonTouch.getMovement(this, movement);
skeletonSprite.skeleton.x += movement.x / skeletonSprite.scale;
skeletonSprite.skeleton.y += movement.y / skeletonSprite.scale;
skeletonSprite.x += movement.x;
skeletonSprite.y += movement.y;
skeletonSprite.skeleton.physicsTranslate(
movement.x / skeletonSprite.scale,
movement.y / skeletonSprite.scale,
);
}
} else {
var sceneTouch = e.getTouch(this);
Expand All @@ -89,7 +93,7 @@ class CelestialCircusExample extends Scene {
}
}


}

}

0 comments on commit 538c4ed

Please sign in to comment.