Does the HTML5 engine have any APIs I can interact with?

There is limited interaction a user can have with the HTML5 engine. The following functions are available:

gse.pauseGame(); // Pauses the Game

gse.playGame(); // Resumes the Game

gse.resetGame(); // Resets the Game

gse.getGameVolume(); // Gets the engine volume

On the sample-index.html file provide, inside the gse.ready callback function, you will see a playerDelegate object which has 3 delegate functions defined. These two actually trigger on engine events:

onLoadingBegin = function() { /* define what you want to happen while the engine is loading a scene */ }

onLoadingEnd = function() { /* define what you want to happen when the engine is done loading a scene */ }

You can also add callbacks for the following actions:

onCurrentSceneChanged = function(sceneKey, scenename) { /* define what extra actions to take when the scene changes. good for analytics or ads */

onShowBannerShow = function(position[‘top’|’bottom’]) { /* define what to do when the show banner behavior is triggered */

onTweetSheet = function(message) { /* Define what happens when the tweet sheet behavior is invoked */ }

You can also write functionality to control the volume of the game inside the gse.ready callback.  Inside that callback you can call the following two functions:

gse.setGameVolume(engine, volume[0-1]); // Sets the volume for the whole game. Must be called where the engine context is available. This can be hooked up in the gse.ready callbackback function.  This must happen inside the gse.ready callback, because you can only set the volume after the engine has initialized.

 

Was this article helpful?