1 decade ago by Bushstar
I have created an entity that when the player walks into it another game will load. I'm planning on using this to load in cut scenes. The code is below at the bottom. Currently it is hard coded to load a specific game. I want to make this dynamic but cannot get the game to load from an entity key I created for it in WM. In WM for the gameLoader entity I've set a "game: IntroScreen" key pair. I've tried to parse it using the following code.
Then passed gameName to ig.system.setGame. It just generated an error in Firebug which says "gameClass is not a constructor" and "setGameNow(gameClass='IntroScreen'", the second part shows that it is picking up the key pair from WM.
How can I make this loading of a game from an entity dynamic?
var gameName = this.game.replace(/^(Level)?(\w)(\w*)/, function( m, l, a, b ) {return a.toUpperCase() + b;});
Then passed gameName to ig.system.setGame. It just generated an error in Firebug which says "gameClass is not a constructor" and "setGameNow(gameClass='IntroScreen'", the second part shows that it is picking up the key pair from WM.
How can I make this loading of a game from an entity dynamic?
ig.module( 'game.entities.gameloader' ) .requires( 'impact.game', 'impact.entity' ) .defines(function(){ EntityGameloader = ig.Entity.extend({ _wmDrawBox: true, _wmBoxColor: 'rgba(0, 0, 255, 0.7)', size: {x: 10, y: 10}, game: null, checkAgainst: ig.Entity.TYPE.A, update: function(){}, check: function( other ) { if(other instanceof EntityPlayer){ if( this.game ) { ig.system.setGame(IntroScreen); } } } }); });