device.onReady

onReady(fn: Function) → {}

specify a function to execute when the Device is fully loaded and ready

 // small game skeleton
 let game = {
    // called by the me.device.onReady function
    onload = function () {
       // init video
       if (!me.video.init('screen', 640, 480, true)) {
          alert("Sorry but your browser does not support html 5 canvas.");
          return;
       }

       // initialize the "audio"
       me.audio.init("mp3,ogg");

       // set callback for ressources loaded event
       me.loader.onload = this.loaded.bind(this);

       // set all ressources to be loaded
       me.loader.preload(game.assets);

       // load everything & display a loading screen
       me.state.change(me.state.LOADING);
    };

    // callback when everything is loaded
    loaded = function () {
       // define stuff
       // ....

       // change to the menu screen
       me.state.change(me.state.PLAY);
    }
 }; // game

 // "bootstrap"
 me.device.onReady(function () {
    game.onload();
 });
Parameters:
Name Type Description
fn Function

the function to be executed

Returns:
Type Description
Powered by webdoc!