Hey Gan, GM had a command called spritePath which moved a sprite from it's current location to a specified location, drawing the sprite x amount of times along the way. For example:
sprite spriteIndex 0 0 "Elf.gif"
spritePath spriteIndex 100 100 4
That would draw a sprite at 0px, then draw it at 25px, 50px, 75px, and finally 100px. But here's the important bit: any code that comes after the spritePath command is only executed after the animation sequence. I can't figure out how to make an equivalent method in in JavaScript. Any ideas?
I think the easiest would be to use a setTimeout. setTimeout runs code after a delay.
setTimeout(function() {
//Code to run after delay
},millisecondDelay);
Here's an example animation
moveSprite(myCharacter, 0, 100);
setTimeout(function() {
moveSprite(myCharacter, 25, 100);
setTimeout(function() {
moveSprite(myCharacter, 50, 100);
setTimeout(function() {
moveSprite(myCharacter, 75, 100);
setTimeout(function() {
moveSprite(myCharacter, 100, 100);
setTimeout(function() {
//Do other stuff after animation
}, 50);
}, 50);
}, 50);
}, 50);
}, 50);
It's not very pretty but it should get the job done.
If this isn't what you want, point me to your code with a description of what you'd like and I'll come up with a solution.