Skip to content

Commit

Permalink
Merge pull request #204 from QuantumCoderQC/fix-tilesheet
Browse files Browse the repository at this point in the history
Fix Tilesheet Frame and Time
  • Loading branch information
luboslenco authored Jan 9, 2024
2 parents 6a791e0 + 0c4b7f3 commit f4fd0b2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Sources/iron/object/Tilesheet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Tilesheet {
}
setFrame(action.start);
paused = false;
time = 0.0;
}

public function pause() {
Expand Down Expand Up @@ -100,16 +101,17 @@ class Tilesheet {
function setFrame(f: Int) {
frame = f;

var tx = frame % raw.tilesx;
var ty = Std.int(frame / raw.tilesx);
tileX = tx * (1 / raw.tilesx);
tileY = ty * (1 / raw.tilesy);

// Action end
if (frame >= action.end && action.start < action.end) {
if (frame > action.end && action.start < action.end) {
if (onActionComplete != null) onActionComplete();
if (action.loop) setFrame(action.start);
else paused = true;
return;
}

var tx = frame % raw.tilesx;
var ty = Std.int(frame / raw.tilesx);
tileX = tx * (1 / raw.tilesx);
tileY = ty * (1 / raw.tilesy);
}
}

0 comments on commit f4fd0b2

Please sign in to comment.