1 decade ago by gort
I am wondering, how would you save a player's place, like, which level he/she was on? I already treid. hers my code:
Some one! PLEASE! awnser soon!!
By the way, all my requires have been given a once-over.
//main.js var GameInfo = function () { this.points = 0; this.level = "Level1" } MyGame = ig.Box2DGame.extend({ gravity: 100, // All entities are affected by this GameInfo: new GameInfo(), // Load a font font: new ig.Font( 'media/04b03.font.png' ), init: function() { // Bind keys ig.input.bind( ig.KEY.LEFT_ARROW, 'left' ); ig.input.bind( ig.KEY.RIGHT_ARROW, 'right' ); ig.input.bind( ig.KEY.UP_ARROW, 'jump' ); ig.input.bind( ig.KEY.DOWN_ARROW, 'down' ); ig.input.bind( ig.KEY.SPACE, 'shoot' ); this.loadLevel( 'Level' + this.GameInfo.level ); }, loadLevel: function( data ) { this.parent( data ); for( var i = 0; i < this.backgroundMaps.length; i++ ) { this.backgroundMaps[i].preRender = true; } },
//levelexit.js ig.module( 'game.entities.levelexit' ) .requires( 'impact.entity' ) .defines(function () { EntityLevelexit = ig.Entity.extend({ _wmScalable : true, gameOverTest: false, _wmDrawBox: true, _wmBoxColor: 'rgba( 0, 0, 255, 0.7 )', size: { x: 8, y: 8 }, level: null, checkAgainst: ig.Entity.TYPE.A, update: function () {}, check: function ( other ) { if ( other instanceof EntityPlayer && ig.game.getEntitiesByType(EntityCrate).length <= 0 && ig.game.getEntitiesByType(EntityMonster).length <= 0) { this.nextLevel() } }, nextLevel: function () { if ( this.level ){ var levelName = this.level.replace(/^(Level)?(\w)(\w*)/, function (m, l, a, b) { return a.toUpperCase() + b; }); ig.game.GameInfo.level = levelName ig.game.loadLevelDeferred(ig.global['Level' + levelName]); console.log('Level' +levelName); } }, }); });
Some one! PLEASE! awnser soon!!
By the way, all my requires have been given a once-over.