jake142
1
Im trying to destroy bullets on collision with my tiles, but all callbacks seems to be null.
this.physics.add.collider(groundLayer, this.weapon.bullets, this.collideCallback, this.processCallback, this);
Can anyone help me on how to destroy bullets when they hit my groundlayer?
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: ‘arcade’,
arcade: {
gravity: {y: 500},
debug: false
}
},
scene: {
key: ‘main’,
preload: preload,
create: create,
update: update
},
};
jake142
2
My bad, got the callback working
this.physics.add.collider(groundLayer, this.weapon.bullets, collideCallback(), processCallback(), this);
But it is only called when the game inits.
How can I kill the bullets that hit the tiles?
jake142
3
Fixed it.
function create() {
…
this.physics.add.collider(this.weapon.bullets, groundLayer, bulletCollide, null, this);
…
}
function bulletCollide (bullet, groundLayer) {
bullet.kill();
}
1 Like