-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infinite loop that can be used to run main game updates, etc.
- Loading branch information
Showing
4 changed files
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Sequencr.js V2 | ||
Sequencr.js V3 | ||
The MIT License (MIT) | ||
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js | ||
|
@@ -35,6 +35,15 @@ function Sequencr() { | |
onCompleted.call(this); | ||
} | ||
} | ||
|
||
this.do = function (callback, timeout) { | ||
setTimeout(function (This) { | ||
var ret = callback.call(This); | ||
if(ret !== false){ | ||
Sequencr.do.apply(This, [callback, timeout]); | ||
} | ||
}, timeout, this); | ||
} | ||
} | ||
|
||
var Sequencr = new Sequencr(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Sequencr.js V2 | ||
Sequencr.js V3 | ||
The MIT License (MIT) | ||
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js | ||
|
@@ -12,4 +12,4 @@ and to permit persons to whom the Software is furnished to do so, subject to the | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
*/ | ||
|
||
function Sequencr(){this.chain=function(n,c){Sequencr["for"].apply(this,[0,n.length,function(c){n[c].call(this)},c])},this["for"]=function(n,c,t,e,i){c>n?setTimeout(function(l){var u=t.call(l,n);u!==!1?Sequencr["for"].apply(l,[n+1,c,t,e,i]):i&&i.call(this)},e,this):i&&i.call(this)}}var Sequencr=new Sequencr; | ||
function Sequencr(){this.chain=function(n,t){Sequencr["for"].apply(this,[0,n.length,function(t){n[t].call(this)},t])},this["for"]=function(n,t,c,i,e){t>n?setTimeout(function(u){var l=c.call(u,n);l!==!1?Sequencr["for"].apply(u,[n+1,t,c,i,e]):e&&e.call(this)},i,this):e&&e.call(this)},this["do"]=function(n,t){setTimeout(function(c){var i=n.call(c);i!==!1&&Sequencr["do"].apply(c,[n,t])},t,this)}}var Sequencr=new Sequencr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
#Changes | ||
V3 - 2016-06-10 | ||
Added Sequencr.do, which is an infinite version of Sequencr.for that can also be exited by returning false in the callback. Use it for your game's animation loop or whatever. | ||
|
||
V2 - 2016-06-09 | ||
Added ability to break out of a for loop by returning false. This will immediately invoke the onCompleted callback. |