Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
Last active December 14, 2015 20:38
Show Gist options
  • Save unstoppablecarl/5144969 to your computer and use it in GitHub Desktop.
Save unstoppablecarl/5144969 to your computer and use it in GitHub Desktop.
MyGame = new ig.Game.extend({
levelToLoad: level1,
// levelName ex: test3
changeLevel: function(levelName){
// prepend and capitalize
var levelObjName = 'Level' + levelName.charAt(0).toUpperCase() + levelName.slice(1),
levelPath = 'game.levels.' + levelName;
delete ig.modules['dom.ready']; // reset dom event handler
delete ig.modules['dummy.loader'];
// tell impact to load the level module
ig
.module('dummy.loader')
.requires(levelPath)
.defines(function(){
MyGame.prototype.levelToLoad = ig.global[levelObjName];
ig.system.setGame(MyGame);
});
// force the module load
ig._execModules();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment