KinoftheFlames Posted November 15, 2015 Share Posted November 15, 2015 I realized I had an older version of Phaser so I updated to v2.4.4 and started seeing this issue:Uncaught TypeError: Cannot read property 'x' of undefinedPhaser.Physics.Arcade.Body.preUpdate @ phaser.js:82607Phaser.Component.PhysicsBody.preUpdate @ phaser.js:45311Phaser.Graphics.preUpdate @ phaser.js:52569Phaser.Component.Core.preUpdate @ phaser.js:43691Phaser.Sprite.preUpdate @ phaser.js:46816Phaser.Group.preUpdate @ phaser.js:32470Phaser.Stage.preUpdate @ phaser.js:30840Phaser.Game.updateLogic @ phaser.js:34677Phaser.Game.update @ phaser.js:34619Phaser.RequestAnimationFrame.updateRAF @ phaser.js:58258_onLoop @ phaser.js:58242originating from this section of code in preUpload for the physics body:// 82607 phaser.js v2.4.4this.position.x = (this.sprite.world.x - (this.sprite.anchor.x * this.width)) + this.offset.x;this.position.y = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;This is related to me adding a graphics body as a child to a physics body of a sprite:gfxBall = game.add.graphics(0, 0);gfxBall.beginFill(0xFFFFFF, 1);gfxBall.drawRect(0, 0, infoBall.size, infoBall.size);...var newBall = game.add.sprite(game.world.width/2 - infoBall.size/2, game.world.height/2 - infoBall.size/2);newBall.addChild(gfxBall);game.physics.arcade.enable(newBall);newBall.body.width = infoBall.size;newBall.body.height = infoBall.size;newBall.body.collideWorldBounds = true;I changed phaser.js to bypass the issue, I just wanted to report it:this.position.x = (this.sprite.world.x - (this.sprite.anchor ? this.sprite.anchor.x : 0 * this.width)) + this.offset.x;this.position.y = (this.sprite.world.y - (this.sprite.anchor ? this.sprite.anchor.y : 0 * this.height)) + this.offset.y; Link to comment Share on other sites More sharing options...
yfarawi Posted November 16, 2015 Share Posted November 16, 2015 Thank you so much,KinoftheFlamesI faced the same problem , now solved by changing the two lines you provided , Link to comment Share on other sites More sharing options...
yfarawi Posted November 16, 2015 Share Posted November 16, 2015 Sorry , changing the script brought another bigger problem , there is a workaround here , https://github.com/photonstorm/phaser/issues/1787 Link to comment Share on other sites More sharing options...
Recommended Posts