Hi all,
I want to remove the collision using ‘removeCollider’, but it doesn’t work. Could anyone help me?
//path
this.curve = new Phaser.Curves.Line(new Phaser.Math.Vector2(50,250), new Phaser.Math.Vector2(550,250));
this.graphics = this.add.graphics();
this.graphics.lineStyle(2, 0xffffff, 1);
this.curve.draw(this.graphics);
this.card = this.add.follower(this.curve, 100, 250, 'card');
this.card.startFollow({
duration: 5000,
yoyo: true,
repeat: -1,
})
this.input.on('pointerdown', function (pointer) {
this.tweens.add({
targets: this.card,
y: { value: 3000, duration: 1500}
});
//collision
this.physics.add.existing(this.card)
this.physics.add.existing(this.carditem)
this.physics.add.existing(this.carditem2)
this.cardcol = this.physics.add.collider(this.carditem, this.card, this.onCollideHandler, null, this)
this.cardcol2 = this.physics.add.collider(this.carditem2, this.card, this.onCollideHandler, null, this)
}, this);
}
onCollideHandler () {
this.destroyed = this.add.sprite(game.config.width/2, 800, "destroyed" );
this.tweens.add({
targets: this.destroyed,
y: { value: 3000, duration: 1500}
})
this.physics.world.removeCollider(this.cardcol)
this.physics.world.removeCollider(this.cardcol2)
}