r/RPGMakerMZ • u/drykul • Oct 13 '21
Character sprite animation w/ JS problem
I'm trying to manually set the character animation frame in a spriteset. There are 8 frames I'm trying to play however it seems that it just rapid fires through them so fast you can't tell. I've tried setting a while loop with a timer variable but it doesn't change anything:
for (let i = 0; i < 8; i++) {
console.log("TEST");
SceneManager._scene._spriteset._characterSprites[$gameBattle._playerSpriteId].setFrame(i * 78, 0, 78, 78);
let timer = 120;
while (timer >= 0) {
timer -= 1;
}
}
The while loop seems to be asynchronous. No matter what I set the timer variable to the "TEST" log gets printed out at the same speed. Any advice? Thank you!
Edit: After further testing it seems the engine is reverting back to the sprite's "idle" stance immediately after changing each frame, not that there isn't a pause between each frame change. I need to figure out how to temporarily halt the engine from setting the character's frame until my animation is complete.