Fixed animation glitch for Lejana

This commit is contained in:
2023-03-05 16:38:38 +11:00
parent 3988412a6a
commit d517949f53

View File

@@ -26,26 +26,36 @@ var motionY: int = 0;
var inputX: int = 0; //cache the keyboard input var inputX: int = 0; //cache the keyboard input
var inputY: int = 0; var inputY: int = 0;
var direction: int = null; //BUGFIX: animation not looping properly
//polyfills - animating different cycles on one image //polyfills - animating different cycles on one image
var stepCount: int = 0; var stepCount: int = 0;
fn faceDown(node: opaque) { fn faceDown(node: opaque) {
if (direction == 0) return;
direction = 0;
node.setNodeRect(0, 0, 32, 32); node.setNodeRect(0, 0, 32, 32);
node.setNodeFrames(4); node.setNodeFrames(4);
} }
fn faceUp(node: opaque) { fn faceUp(node: opaque) {
if (direction == 1) return;
direction = 1;
node.setNodeRect(32 * 4, 0, 32, 32); node.setNodeRect(32 * 4, 0, 32, 32);
node.setNodeFrames(4); node.setNodeFrames(4);
} }
fn faceLeft(node: opaque) { fn faceLeft(node: opaque) {
if (direction == 3) return;
direction = 3;
node.setNodeRect(32 * 12, 0, 32, 32); node.setNodeRect(32 * 12, 0, 32, 32);
node.setNodeFrames(4); node.setNodeFrames(4);
} }
fn faceRight(node: opaque) { fn faceRight(node: opaque) {
if (direction == 2) return;
direction = 2;
node.setNodeRect(32 * 8, 0, 32, 32); node.setNodeRect(32 * 8, 0, 32, 32);
node.setNodeFrames(4); node.setNodeFrames(4);
} }
@@ -111,7 +121,7 @@ fn onStep(node: opaque) {
} }
//animation //animation
if (motionX == 0 && motionY == 0) { if (motionX == 0 && motionY == 0 && inputX == 0 && inputY == 0) {
stepCount = 0; stepCount = 0;
node.setCurrentNodeFrame(0); node.setCurrentNodeFrame(0);
} }