diff --git a/src/components/Turtle.ts b/src/components/Turtle.ts index bc379e8..1a0c554 100644 --- a/src/components/Turtle.ts +++ b/src/components/Turtle.ts @@ -34,7 +34,7 @@ export class Turtle extends Button { this.spriteSize = 200; this.sprite = this.scene.physics.add.sprite(0, 0, "turtle_waiting"); this.sprite.setGravityY(constants.physics.gravity); - this.sprite.setCollideWorldBounds(true) + this.sprite.setCollideWorldBounds(true, 1, 1, true); this.sprite.setBounceY(0.4); this.sprite.setOrigin(0.5, 1.0); this.sprite.y += this.spriteSize / 2; diff --git a/src/scenes/OverworldState.ts b/src/scenes/OverworldState.ts index aabfbbc..ee4b4de 100644 --- a/src/scenes/OverworldState.ts +++ b/src/scenes/OverworldState.ts @@ -64,7 +64,11 @@ export class OverworldState extends Phaser.GameObjects.Container { this.scene.physics.add.collider(turtle.sprite, this.trampoline.sprite, () => { turtle.sprite.setVelocityY(-800 + (Math.random()*100-50)); - }) + }); + + this.scene.physics.world.on('worldbounds', (body: any) => { + // world collision event + }); turtle.on("action", () => { turtle.doABarrelRoll();