Home

Awesome

fnDelay

Copyright (C) 2012, Greg Houston

fnDelay is licensed under the MIT License

About fnDelay

fnDelay allows you to delay a function in MelonJS using the game logic timer.

Register fnDelay

To register the plugin:

me.plugin.register(FnDelay, "fnDelay");

Syntax

me.plugin.fnDelay.add(fn, delay); 

Or:

me.plugin.fnDelay.add(fn, delay, settings);

Example

me.plugin.fnDelay.add(jsApp.addEnemy, 500, {
    args: [type, spawnPoint, exitPoint],
    // count is the number of times to repeat the function; defaults to 1
    count: 3,
    // setting firstNow to true will run the function the first time without a delay; defaults to false 
    firstNow: true, 
    // onComplete is fired after the function has been repeated the number of times in count
    onComplete: function(){ jsApp.nextWaveGroup(); } 
});