1 decade ago by andrecaribe
Hi! My Problem...
Chrome returns to me:
My code:
What is wrong? Is a bug? How to resolve this?
Chrome returns to me:
Uncaught TypeError: Cannot call method 'SetDebugDraw' of undefined ig.Box2DDebug.ig.Class.extend.drawdebug.js:41 ig.Box2DGame.extend.drawmain.js:60 window.ig.Class.extend.prototype.(anonymous function)impact.js:404 ig.Game.ig.Class.extend.rungame.js:154 ig.System.ig.Class.extend.runsystem.js:101 (anonymous function)
My code:
ig.module( 'game.main' ) .requires( 'impact.game', 'impact.font', 'game.entities.player', 'game.levels.level1', 'plugins.box2d.game', 'plugins.box2d.debug' ) .defines(function(){ MyGame = ig.Box2DGame.extend({ gravity: 100, // Load a font font: new ig.Font( 'media/04b03.font.png' ), init: function() { // Debug this.debugDrawer = new ig.Box2DDebug( ig.world ); // Keys ig.input.bind( ig.KEY.LEFT_ARROW, 'left' ); ig.input.bind( ig.KEY.RIGHT_ARROW, 'right' ); // Level this.loadLevel( LevelLevel1 ); // Player ig.game.spawnEntity( EntityPlayer, 100, 300 ); }, loadLevel: function( data ) { this.parent( data ); for( var i = 0; i < this.backgroundMaps.length; i++ ) { this.backgroundMaps[i].preRender = true; } }, update: function() { this.parent(); // Player var player = this.getEntitiesByType( EntityPlayer )[0]; // Camera if( player ) { this.screen.x = player.pos.x - ig.system.width/2; this.screen.y = player.pos.y - ig.system.height/2 - 48; } }, draw: function() { this.parent(); this.debugDrawer.draw(); } }); ig.main( '#canvas', MyGame, 60, 512, 512, 1 ); });
What is wrong? Is a bug? How to resolve this?