MattS Posted March 17, 2014 Share Posted March 17, 2014 I have been following along with the Advanced Phaser and Typescript Project tutorial and have seem to run into a slight issue. It seems that within the Player.ts the code breaks on the line game.add.existing(this) My code is exactly the same as it is in the tutorial, so what could be causing the problem? Link to comment Share on other sites More sharing options...
MattS Posted March 17, 2014 Author Share Posted March 17, 2014 I forgot to mention that the error reported to the console. TypeError: this.body is null Anyone know a workaround for this? Link to comment Share on other sites More sharing options...
mariogarranz Posted March 17, 2014 Share Posted March 17, 2014 Since Phaser 2, sprites body is null until you activate them into any Physics system. That's probably the cause of your error. Since I guess that tutorial is written for 1.1.x, it will use Arcade Physics. Try this:game.physics.enable(this);game.add.existing(this);Anyway, Phaser changed a lot in version 2, so you could either download 1.1.6 and do the tutorial with it, or just stick to 2 and probably deal with some more errors like this, looking into version changes and docs. Link to comment Share on other sites More sharing options...
MattS Posted March 17, 2014 Author Share Posted March 17, 2014 I try to do that but it just returns an error when I try to build. The property 'enable' does not exist on value of type 'Phaser.Physics.Arcade.World'. Link to comment Share on other sites More sharing options...
mariogarranz Posted March 18, 2014 Share Posted March 18, 2014 What Phaser version are you using? Link to comment Share on other sites More sharing options...
rich Posted March 19, 2014 Share Posted March 19, 2014 Sorry none of those tutorials have been updated for 2.0 yet. Link to comment Share on other sites More sharing options...
MattS Posted March 19, 2014 Author Share Posted March 19, 2014 I'm using the most up to date Phaser. I have also tried switching to the dev branch with no luck. Link to comment Share on other sites More sharing options...
MattS Posted March 20, 2014 Author Share Posted March 20, 2014 It doesn't make sense because transitioning other code from 1.1.x to 2.0 worked. For example: this.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;this.stage.scale.minWidth = 480;this.stage.scale.minHeight = 260;this.stage.scale.maxWidth = 1024;this.stage.scale.maxHeight = 768;this.stage.scale.forceLandscape = true;this.stage.scale.pageAlignHorizontally = true;this.stage.scale.setScreenSize(true);now works fine as:this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;this.game.scale.minWidth = 480;this.game.scale.minHeight = 260;this.game.scale.maxWidth = 1024;this.game.scale.maxHeight = 768;this.game.scale.forceLandscape = true;this.game.scale.pageAlignHorizontally = true;this.game.scale.setScreenSize(true);So why doesn't game.physics.enable work, or even exist for that matter? Link to comment Share on other sites More sharing options...
Recommended Posts