[phaser] collider-충돌테스트

[phaser] collider-충돌테스트 updated_at: 2023-12-05 16:24

collider

phaser 3.7x

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);

  
});

phaser 3.5x

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);

  
});

Table of contents 목차

평점을 남겨주세요
평점 : 5.0
총 투표수 : 1

질문 및 답글