I think this is what you are looking for:
for (let i = 0; i < data.numChanges; i++) {
console.log("Try numebr #" + i);
this.enemy.image = 'images/items/glasses/glasses.png;
//Wait 2 seconds, and show this image:
setTimeout(() => this.enemy.image = oldImage, 2000);
setTimeout(() => ...some code, 1000)
}
Basically you end your code in setTimeout(() => ..some code, 2000), 2000 is the timeout in ms, so 2000ms == 2s.
source
share