-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopBar.js
More file actions
58 lines (50 loc) · 1.27 KB
/
TopBar.js
File metadata and controls
58 lines (50 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import Phaser from "phaser";
import Config from "../Config";
export default class TopBar extends Phaser.GameObjects.Graphics {
constructor(scene) {
super(scene);
// score, level 들어가는 배경
this.fillStyle(0x28288c)
.fillRect(0, 0, Config.width, 30)
.setDepth(90)
.setScrollFactor(0);
this.m_score = 0;
this.m_scoreLabel = scene.add
.bitmapText(
5,
1,
"pixelFont",
`MOBS KILLED ${this.m_score.toString().padStart(6, "0")}`,
40
)
.setScrollFactor(0)
.setDepth(100);
this.m_level = 1;
this.m_levelLabel = scene.add
.bitmapText(
650,
1,
"pixelFont",
`LEVEL ${this.m_level.toString().padStart(3, "0")}`,
40
)
.setScrollFactor(0)
.setDepth(100);
scene.add.existing(this);
}
gainScore() {
this.m_score += 1;
this.m_scoreLabel.text = `MOBS KILLED ${this.m_score
.toString()
.padStart(6, "0")}`;
}
gainLevel() {
this.m_level += 1;
this.m_levelLabel.text = `LEVEL ${this.m_level
.toString()
.padStart(3, "0")}`;
// 레벨업 할 때마다 max 경험치가 10씩 증가합니다.
this.scene.m_expBar.m_maxExp += 10;
this.scene.m_expBar.reset();
}
}