dieter91 Posted March 23, 2014 Share Posted March 23, 2014 Hi I'm having a problem with using "immovable". This is my code:var game = new Phaser.Game( 800, 600, Phaser.AUTO, '', {preload: preload, create: create, update: update});function preload() { game.load.image('dude', 'images/player.png', 64, 64); game.load.image('platform', 'images/platform.png', 600, 40);}var player;var platform;function create() { game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = "58ACFA"; game.physics.arcade.gravity.y = 250; platform = game.add.sprite(32, 400, 'platform'); player = game.add.sprite(32, 32, 'dude'); game.physics.enable(player, Phaser.Physics.ARCADE); game.physics.enable(platform, Phaser.Physics.ARCADE); game.platform.body.immovable = true; player.body.bounce.y = 0.1; game.camera.follow(player); cursors = game.input.keyboard.createCursorKeys(); jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);}function update() { game.physics.arcade.collide(player, platform); player.body.velocity.x = 0;}This is my error in console: Uncaught TypeError : Cannot read property 'body' of undefined I'm probably doing something stupid Link to comment Share on other sites More sharing options...
JP91 Posted March 23, 2014 Share Posted March 23, 2014 game.platform.body.immovable = true; ???????????? Link to comment Share on other sites More sharing options...
dieter91 Posted March 23, 2014 Author Share Posted March 23, 2014 Ehm, yeah, what? Link to comment Share on other sites More sharing options...
JP91 Posted March 23, 2014 Share Posted March 23, 2014 eheheheheheh platform.body.immovable = true; Link to comment Share on other sites More sharing options...
dieter91 Posted March 23, 2014 Author Share Posted March 23, 2014 I tried that. I get no error now, but the platform still moves. Link to comment Share on other sites More sharing options...
JP91 Posted March 23, 2014 Share Posted March 23, 2014 moves in y ? Link to comment Share on other sites More sharing options...
dieter91 Posted March 23, 2014 Author Share Posted March 23, 2014 Yes, because the gravity. Link to comment Share on other sites More sharing options...
JP91 Posted March 23, 2014 Share Posted March 23, 2014 not sure you want to do but.... object.allowGravity = false; Link to comment Share on other sites More sharing options...
dieter91 Posted March 23, 2014 Author Share Posted March 23, 2014 I want the platform to stand still so my player can walk on it. I got it to work now by using this:platform.body.allowGravity = false;platform.body.immovable = true; Thanks Link to comment Share on other sites More sharing options...
Recommended Posts