Answer the question
In order to leave comments, you need to log in
[Phaser.js] Why is only one object "solid" and the rest are not?
!!! You can pass through the wall, but if you stand on the top of the wall, then the character does not fall through !!!
Hello!
I created a small scene in Phaser.js and made a collision so that mario is on the platform and can't go through the side ones.
But, unfortunately, it stands only on the main platform, which is from below, below it. And it calmly passes through the side walls, although all these walls are in the same group. What's the problem, I can't figure it out :{
CODE
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);
},
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question