Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
So, I recreated setTimeout and Promise in CopperCube. Promise was possible because of the BluebirdJS NPM module, which I used Browserify to make work in CopperCube. Then I recreated setTimeout so BluebirdJS will stop complaining about setTimeout not being defined. Promises allow you asynchronously run code, without freezing/lowering the framerate of your code and do many other things, like run callback methods for async tasks. How to use: 1.) Copy "behavior_bluebird" into "C:/Users/USERNAME/Documents/CopperCube/extensions" 2.) In CopperCube, (Top Menu Bar) "Edit" > "Plugins" > "Reload and Verify Extensions and Plugins" 3.) In each scene you want to use this, attach the "Bluebird Module" on the root scene node only. 4.) Now every other extension used in your scene and any execute javascript action in your scene can use "Promise` and "setTimeout` now! Download: http://www.mediafire.com/file/0t... Documentation: Bluebird: http://bluebirdjs.com/docs/api-r... setTimeout: https://www.w3schools.com/jsref/... |
||||
|
Cool, thanks for posting! |
||||
|
Thanks a lot for sharing this. |
||||
|
Sounds Interesting. In simple terms what does this acheive for games in CopperCube ? - FPS increase ? I don't know what a Promise is... SetTimeout - how is that different to the DoLater function ? |
||||
|
A Promise is an action, that can do something later asynchronously. It comes with ES6 but CopperCube is in ES5. setTimeout is more reliable because it doesn't interrupt the FPS of the game while it waits to do the task. |
||||
|
I have tried this Bluebird extension and had endless setTimeout is not defined messages. Do you have a script example that works ? Also I did get it to work a bit (I think) and load files from the hard drive but causes temporary freezing up...is that normal as I thought it should not affect other code running...? |
||||
|
According to Niko, this Bluebird behavior will only work inside browsers and is not for PC games.... |
|