Jump to content

debugDraw : Uncaught TypeError: Cannot read property 'width' of undefined


Phempt
 Share

Recommended Posts

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 
Link to comment
Share on other sites

Panda's version: 1.9.0

 

Yes, it give me a file and a line number:

debug.js:116

The 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));    }});
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...