lettuce
Version:
Lettuce JS, Mini Mobile Framework for Romantic with DSL.
57 lines (43 loc) • 1.45 kB
JavaScript
/**
* main
*/
var game = {
/**
*
* Initialize the application
*/
onload: function() {
// init the video
if (!me.video.init(800, 600, {wrapper : "screen", scale : 'auto'})) {
alert("Your browser does not support HTML5 canvas.");
return;
}
// Set some default debug flags
me.debug.renderHitBox = true;
// add "#debug" to the URL to enable the debug Panel
if (document.location.hash === "#debug") {
window.onReady(function () {
me.plugin.register.defer(this, me.debug.Panel, "debug", me.input.KEY.V);
});
}
// set all ressources to be loaded
me.loader.onload = this.loaded.bind(this);
// set all ressources to be loaded
me.loader.preload(game.resources);
// load everything & display a loading screen
me.state.change(me.state.LOADING);
},
/**
* callback when everything is loaded
*/
loaded: function () {
// set the "Play/Ingame" Screen Object
me.state.set(me.state.PLAY, new game.PlayScreen());
// set the fade transition effect
me.state.transition("fade","#FFFFFF", 250);
// register our objects entity in the object pool
me.pool.register("mainPlayer", game.PlayerEntity);
// switch to PLAY state
me.state.change(me.state.PLAY);
}
};