Dynamically change effective world bounds

Hi all,

I’ve been searching the forums and typescript typings trying to determine a strategy for slowly shrinking the effective rectangular play area over time, arcade physics. I’ve tried search for:

  • changing the world bounds at runtime, which don’t seem to be exposed from .game/.scene in 3.x
  • creating collidable geometry/path, which i’m not sure is possible to make collidable unless i switch to matter physics instead of arcade physics, which is undesirable for this application
  • creating various invisible collidable objects and move each of them in towards my play area over time. this could work, but seems too complicated for something that i suspect has an otherwise simple solution

any tips? thanks for reading!

i keep updating & repainting a rectangle… just need it to collide!

i converted the Geom rectangle to a GameObject rectangle, and found that there is a world collider provision:

const encroachingBoundary = this.add.rectangle(0, 0, width, height, 0xff0000, 1);
encroachingBoundary.setOrigin(0, 0)
const dvd: Phaser.Physics.Arcade.Image  = this.dvd = this.physics.add.sprite(400, 100, 'dvd')
this.physics.add.collider(encroachingBoundary, dvd, () => {
  return true
}, () => {
  return true

even so, the the collision never triggers. collider takes two GameObjects–and so the typescript compiler and I feel like we are honoring the contract :thinking:

You should be able to modify this.physics.world.bounds directly.

Setting the world bounds is not working. I am extending the world bounds and the code is being ignored.