const rect = this.physics.add.staticSprite(
hedgeImg.x,
hedgeImg.getBounds().bottom,
"box"
)
.setDisplaySize(hedgeImg.displayWidth, 5)
this.rufus = this.physics.add
.sprite(
this.cameras.main.centerX - 100,
this.cameras.main.centerY - 40,
"rufus"
)
.setDisplaySize(140, 140)
.setCollideWorldBounds(true);
this.physics.add.collider(this.rufus, rect, () => {
})
I have a dynamic and static sprite. The dynamic sprite moves around the scene following the pointer. When it collides with the static sprite, I need it to stop moving and not be able to move through/over the static sprite.
How can I properly handle that, can anyone help me with this?
Any help is appreciated.