danmoople Posted January 23, 2017 Share Posted January 23, 2017 Hello everybody! I created a little scene with walls. Bottom wall is solid. But left and right are not. Why? Can you please help me? preload: function() { game.load.image('mario', 'images/mario.png'); game.load.image('WallH', 'images/wallH.png'); game.load.image('WallW', 'images/wallW.png'); }, create: function() { game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = "3984db"; game.physics.arcade.gravity.y = 1200; this.cursor = game.input.keyboard.createCursorKeys(); this.mario = game.add.sprite(game.width / 2, game.height / 2, 'mario'); this.mario.anchor.setTo(0.5,0.5); this.mario.scale.setTo(0.15,0.15); this.walls = game.add.group(); this.walls.enableBody = true; this.walls.enableBody = true; this.downWallH = game.add.sprite(0, 540, 'WallH', 0, this.walls); this.leftWallW = game.add.sprite(0,0, 'WallW', 0, this.walls); this.rightWallW = game.add.sprite(822,0, 'WallW', 0, this.walls); game.physics.arcade.enable(this.mario); this.walls.setAll('body.allowGravity', false); this.walls.setAll('body.immovable', true); }, ... Link to comment Share on other sites More sharing options...
phreaknation Posted January 23, 2017 Share Posted January 23, 2017 have you tried debugging the physics? Link to comment Share on other sites More sharing options...
anthkris Posted January 24, 2017 Share Posted January 24, 2017 I have a similar question, so any help would be appreciated! Link to comment Share on other sites More sharing options...
samme Posted January 24, 2017 Share Posted January 24, 2017 You need to collide walls vs player at least. Link to comment Share on other sites More sharing options...
anthkris Posted January 25, 2017 Share Posted January 25, 2017 @samme In my case, I definitely am checking collision between walls and player and I've verified that walls show they were being touched, but the player still falls through. Link to comment Share on other sites More sharing options...
anthkris Posted January 25, 2017 Share Posted January 25, 2017 @danmoople Don't know if this will help, but in my case, I was altering the player's position with player.x, which was interfering with collision detection. Once I commented out that line, collision worked as expected. Link to comment Share on other sites More sharing options...
Recommended Posts