Skip to content

Instantly share code, notes, and snippets.

@AleBles
Last active December 6, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AleBles/9ecafdb7b2df5006cc0fa8d97ccd9016 to your computer and use it in GitHub Desktop.
Save AleBles/9ecafdb7b2df5006cc0fa8d97ccd9016 to your computer and use it in GitHub Desktop.
class Pipe extends Phaser.Sprite {
public giveScore: boolean = true;
constructor(game: Phaser.Game, x: number, y: number, key: string) {
super(game, x, y, key);
this.game.physics.enable(this, Phaser.Physics.ARCADE);
this.body.velocity.x = speed;
}
public update(): void {
if(this.x+this.width<bird.x && this.giveScore){
score+=0.5;
updateScore();
this.giveScore = false;
}
if(this.x <= this.width) {
this.destroy();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment