Crafty Time

Back to top

.delay

public this.delay(Function callback, Number delay)

callback
Method to execute after given amount of milliseconds
delay
Amount of milliseconds to execute the method

The delay method will execute a function after a given amount of time in milliseconds.

It is not a wrapper for setTimeout.

If Crafty is paused, the delay is interrupted with the pause and then resume when unpaused

If the entity is destroyed, the delay is also destroyed and will not have effect.

Example

console.log("start");
this.delay(function() {
         console.log("100ms later");
}, 100);