I have this bug/logic error that I couldn't figure out. My player does detect collision with the tiles with its top and bottom, but not its sides. The player is an instance of a class that extends Phaser.GameObjects.Rectangle. I tried changing it to Phaser.GameObjects.Sprite, but the same problem occurs.
this.player.body.collideWorldBounds = true
this.foregroundLayer.setCollisionBetween(1, 200)
this.physics.add.collider(this.player, this.foregroundLayer)
In the update method
this.physics.collide(this.player, this.foregroundLayer)
The orange is the debugGraphics, and as you can see, the player(box), doesn't collide with the tiles horizontally. What is causing this? TIA.
Welp, the error was how I defined the movement. I have to use
this.body.x += this.speed
instead of
this.x += this.speed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.