|
@@ -22,6 +22,10 @@ export default ({ el, center, rotateSpeed = 0.015, speed = -5 }) => {
|
22
|
22
|
// 事件发射器
|
23
|
23
|
const _evt = new Two.Events();
|
24
|
24
|
|
|
25
|
+ // 游戏状态, 0 未开始, 1进行中, 2已结束
|
|
26
|
+ const status = 0;
|
|
27
|
+ const getGameState = () => status;
|
|
28
|
+
|
25
|
29
|
// 绘制背景
|
26
|
30
|
drawBg({ two, center });
|
27
|
31
|
|
|
@@ -41,7 +45,7 @@ export default ({ el, center, rotateSpeed = 0.015, speed = -5 }) => {
|
41
|
45
|
const counter = drawCounter({ two, center })
|
42
|
46
|
|
43
|
47
|
// 绘制子弹
|
44
|
|
- const clip = drawBullets({two, center, speed })
|
|
48
|
+ const clip = drawBullets({two, center, speed, getGameState })
|
45
|
49
|
|
46
|
50
|
// 整体绘制结束
|
47
|
51
|
two.update();
|
|
@@ -52,6 +56,7 @@ export default ({ el, center, rotateSpeed = 0.015, speed = -5 }) => {
|
52
|
56
|
function gameOver(isSuccess) {
|
53
|
57
|
// 停止摩天轮旋转
|
54
|
58
|
wheel.stop();
|
|
59
|
+ status = 1; // 游戏结束
|
55
|
60
|
|
56
|
61
|
const t = setTimeout(() => {
|
57
|
62
|
clearTimeout(t)
|
|
@@ -101,6 +106,7 @@ export default ({ el, center, rotateSpeed = 0.015, speed = -5 }) => {
|
101
|
106
|
on: _evt.on.bind(_evt),
|
102
|
107
|
fire: clip.shoot,
|
103
|
108
|
play: () => {
|
|
109
|
+ status = 1; // 游戏开始
|
104
|
110
|
clip.bulletLoad() // 先上膛一颗子弹
|
105
|
111
|
wheel.rotate();
|
106
|
112
|
two.play();
|