generated from Chocobois/choco-jam-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
233 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { GameScene } from "@/scenes/GameScene"; | ||
|
||
export class Timer extends Phaser.GameObjects.Container { | ||
private background: Phaser.GameObjects.Image; | ||
private graphics: Phaser.GameObjects.Graphics; | ||
private size: number; | ||
private color: number; | ||
|
||
constructor( | ||
scene: GameScene, | ||
x: number, | ||
y: number, | ||
size: number, | ||
color: number | ||
) { | ||
super(scene, x, y); | ||
scene.add.existing(this); | ||
this.scene = scene; | ||
this.size = size; | ||
this.color = color; | ||
|
||
this.background = this.scene.add.image(0, 0, "timer"); | ||
this.background.setScale(size / this.background.width); | ||
this.add(this.background); | ||
|
||
this.graphics = this.scene.add.graphics(); | ||
this.add(this.graphics); | ||
} | ||
|
||
setColor(color: number) { | ||
this.color = color; | ||
} | ||
|
||
redraw(factor: number) { | ||
const radius = 0.24 * this.size; | ||
const border = 0.055 * this.size; | ||
|
||
this.graphics.clear(); | ||
this.graphics.beginPath(); | ||
this.graphics.fillStyle(this.color); | ||
this.graphics.moveTo(0, 0); | ||
this.graphics.arc( | ||
0, | ||
0, | ||
radius - border, | ||
-Math.PI / 2, | ||
-Math.PI / 2 + factor * 2 * Math.PI | ||
); | ||
this.graphics.closePath(); | ||
this.graphics.fillPath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.