collide(object1, [object2], [collideCallback], [processCallback], [callbackContext])
this.physics.add.collider(this.ball, this.bricks, (ball:any, brick:any) => {
this.add.tween({
targets : brick,
scaleX: 0.5,
scaleY: 0.5,
ease: 'linear',
duration : 200,
repeat: 0,
yoyo: false,
onComplete: () => {
brick.destroy();
if (this.bricks.countActive(true) == 0) {
alert('You won the game, congratulations!');
location.reload();
}
},
onCompleteScope: this
});
this.ball.anims.play('wobble');
this.score += 10;
this.scoreText.setText('Points: ' + this.score);
});
this.physics.add.collider(this.ball, this.bricks, (ball:Phaser.GameObjects.GameObject, brick:Phaser.GameObjects.GameObject) => {
// brick.destroy();
this.add.tween({
targets : brick,
scaleX: 0.5,
scaleY: 0.5,
ease: 'linear',
duration : 200,
repeat: 0,
yoyo: false,
onComplete: () => {
brick.destroy();
if (this.bricks.countActive(true) == 0) {
alert('You won the game, congratulations!');
location.reload();
}
},
onCompleteScope: this
});
this.ball.anims.play('wobble');
this.score += 10;
this.scoreText.setText('Points: ' + this.score);
});