How can I avoid touching the collected items?

I collect items. But there’s a problem. I can jump on them, which is wrong. How can I not jump on them?

Preload func:

this.load.image('ball', 'assets/ball.png')

Create func:

this.balls = this.physics.add.staticGroup({classType: Ball, allowGravity: false, immovable: true })
this.balls.create(1420, 803, 'ball')

Collect func:

this.physics.add.overlap(this.player, this.balls, this.handleCollectBall, undefined, this)

handleCollectBall(player, ball) {
	this.balls.killAndHide(ball)
	this.physics.world.disableBody(ball.body)
}

Maybe you need to use collide instead of overlap.

1 Like