Phempt Posted October 19, 2014 Share Posted October 19, 2014 Hello guys, I tried to add ?debugdraw at the end of my URL, the game doesn't start with this error:Uncaught TypeError: Cannot read property 'width' of undefined I add bodies with: /* TOP BODY */ this.topBody = new game.Body({ position: { x: topX, y: topY }, collisionGroup: 0, collideAgainst: 0, mass: 0, }); this.topBody.collide = this.collide.bind(this); this.topBody.addShape(new game.Rectangle(74, 314)); game.scene.world.addBody(this.topBody); /* BOTTOM BODY */ this.bottomBody = new game.Body({ position: { x: topX, y: topY }, collisionGroup: 0, collideAgainst: 0, mass: 0, }); this.bottomBody.collide = this.collide.bind(this); this.bottomBody.addShape(new game.Rectangle(74, 314)); game.scene.world.addBody(this.bottomBody);Chrome infos:Panda.js 1.9.0 core.js:334Pixi.js 1.6.1 core.js:335Canvas renderer 320x480 core.js:336Web Audio engine core.js:337Test Game 1.0.0 core.js:339836 Uncaught TypeError: Cannot read property 'width' of undefined Quote Link to comment Share on other sites More sharing options...
enpu Posted October 19, 2014 Share Posted October 19, 2014 Can't see anything wrong with your code, can you show your full code?Does the error give you filename and line number? Can't see that in your error. What version are you using? Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 19, 2014 Author Share Posted October 19, 2014 Panda's version: 1.9.0 Yes, it give me a file and a line number:debug.js:116The code is:game.createScene('Main', { backgroundColor: 0x44cce2, tubesArray: [], init: function() { /* WORLD & CONTAINERS */ this.world = new game.World(0, 100); this.secondBGContainer = new game.Container(); this.secondBGContainer.addTo(this.stage); this.containerEnemies = new game.Container(); this.containerEnemies.addTo(this.stage); this.backgroundContainer = new game.Container(); this.backgroundContainer.addTo(this.stage); /* SPRITE BACK */ var brushSprite = new game.Sprite('brush.png'); var terrainSprite = new game.Sprite('terrain.png'); /* Parallax */ this.addParallaxSecondBG(game.system.height - brushSprite.height, 'brush.png', -50); this.addParallax(game.system.height - terrainSprite.height, 'terrain.png', -200); var test = new game.Sprite('box.png'); test.position.set(10,100); test.anchor.set(0.0,0.0); test.addTo(game.scene.containerEnemies); // Use addObject, to get update function called every frame game.scene.addObject(test); /* TOP BODY */ this.testBody = new game.Body({ position: { x: 10, y: 100 }, collisionGroup: 1, collideAgainst: 0, mass: 0, }); this.testBody.collide = this.collide.bind(this); this.testBody.addShape(new game.Rectangle(136, 176)); game.scene.world.addBody(this.testBody); /* TUBES SPAWN */ this.createTubes(); }, collide: function() { console.log("Collision. This line is not called."); return true; }, addParallax: function(y, path, speed) { var parallax = new game.TilingSprite(path); parallax.position.y = y; parallax.speed.x = speed; parallax.addTo(this.backgroundContainer); this.addObject(parallax); }, addParallaxSecondBG: function(y, path, speed) { var parallax = new game.TilingSprite(path); parallax.position.y = y; parallax.speed.x = speed; parallax.addTo(this.secondBGContainer); this.addObject(parallax); }, createTubes: function() { this.tubesArray.push(new game.tubeSpawn()); this.addTimer(3000, this.createTubes.bind(this)); }}); Quote Link to comment Share on other sites More sharing options...
enpu Posted October 19, 2014 Share Posted October 19, 2014 I can't get any error with your code.. Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 19, 2014 Author Share Posted October 19, 2014 The problem seems to be here (debug.js line 116):if (body.width !== body.target.shape.width || body.height !== body.target.shape.height) {My goal is activate the debug mode in order to understand if body is moving with enemies' sprite. Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 19, 2014 Author Share Posted October 19, 2014 With panda 1.8.0:Panda.js 1.8.0 core.js:334Pixi.js 1.6.1 core.js:335Canvas renderer 320x480 core.js:336Web Audio engine core.js:337Test Game 1.0.0 there isn't the error, but no shape are drawn. Looking at debug.js, I saw that in 1.8.0 is a little bit different. Quote Link to comment Share on other sites More sharing options...
enpu Posted October 19, 2014 Share Posted October 19, 2014 There must be something wrong with your code. Can you show or send your full main.js ? Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 19, 2014 Author Share Posted October 19, 2014 I'm preparing the zip file, give me 5 minutes, thank you! Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 19, 2014 Author Share Posted October 19, 2014 Sent! =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.