张延森 3 år sedan
förälder
incheckning
1f6d2fc280

+ 5
- 0
public/index.html Visa fil

10
     为岸线圆梦,摩天轮圆满大作战!
10
     为岸线圆梦,摩天轮圆满大作战!
11
   </title>
11
   </title>
12
   <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
12
   <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
13
+  <!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
14
+  <script>
15
+    // VConsole 默认会挂载到 `window.VConsole` 上
16
+    var vConsole = new window.VConsole();
17
+  </script> -->
13
 </head>
18
 </head>
14
 
19
 
15
 <body>
20
 <body>

+ 20
- 3
src/pages/game/algorithm/index.js Visa fil

8
 import drawBullets from './bullet';
8
 import drawBullets from './bullet';
9
 import { drawCounter } from './counter';
9
 import { drawCounter } from './counter';
10
 
10
 
11
-export default ({ el, center, rotateSpeed = 0.015, speed = -5 }) => {
11
+export default ({ el, center, rotateSpeed = 0.045, speed = -12 }) => {
12
     
12
     
13
   // 修复一个单页面应用, 不能重复加载图片的bug
13
   // 修复一个单页面应用, 不能重复加载图片的bug
14
   Two.Texture.ImageRegistry = new Two.Registry();
14
   Two.Texture.ImageRegistry = new Two.Registry();
15
 
15
 
16
+  // 30FPS
17
+  const FRAMERATE = 1000 / 30;
18
+
16
   // 初始化
19
   // 初始化
17
   const two = new Two({
20
   const two = new Two({
18
     type: Two.Types.svg,
21
     type: Two.Types.svg,
49
 
52
 
50
   // 整体绘制结束  
53
   // 整体绘制结束  
51
   two.update();
54
   two.update();
55
+  // 页面刷新定时器
56
+  let frameRateInterval = null;
52
 
57
 
53
   // 下面是业务逻辑部分
58
   // 下面是业务逻辑部分
54
 
59
 
109
       status = 1; // 游戏开始
114
       status = 1; // 游戏开始
110
       clip.bulletLoad() // 先上膛一颗子弹
115
       clip.bulletLoad() // 先上膛一颗子弹
111
       wheel.rotate();
116
       wheel.rotate();
112
-      two.play();
117
+      // two.play();
118
+
119
+      console.log('----------FRAME RATE---------', FRAMERATE)
120
+
121
+      if (frameRateInterval) {
122
+        clearInterval(frameRateInterval)
123
+      } else {
124
+        setInterval(function() {
125
+          two.update();
126
+        }, FRAMERATE);
127
+      }
113
     },
128
     },
114
     pause: () => {
129
     pause: () => {
115
       wheel.stop();
130
       wheel.stop();
116
-      two.pause();
131
+      // two.pause();
132
+      clearInterval(frameRateInterval)
117
     },
133
     },
118
     destroy: () => {
134
     destroy: () => {
119
       two.unbind('update');
135
       two.unbind('update');
120
       two.pause();
136
       two.pause();
121
       el.removeChild(two.renderer.domElement);
137
       el.removeChild(two.renderer.domElement);
138
+      clearInterval(frameRateInterval);
122
     }
139
     }
123
   }
140
   }
124
 }
141
 }

+ 1
- 1
src/pages/game/algorithm/pedestal.js Visa fil

34
   pedestalBox.scale = scale;
34
   pedestalBox.scale = scale;
35
 
35
 
36
   // 绘制底座上的绳子
36
   // 绘制底座上的绳子
37
-  const ropeSequence = two.makeImageSequence(ropeImageList, x, y, 40); // 40 是不断调式出来的频率, 需要跟 speed 匹配
37
+  const ropeSequence = two.makeImageSequence(ropeImageList, x, y, 30); // 40 是不断调式出来的频率, 需要跟 speed 匹配
38
   ropeSequence.scale = new Two.Vector(scale, scale);
38
   ropeSequence.scale = new Two.Vector(scale, scale);
39
 
39
 
40
   return {
40
   return {

+ 9
- 1
src/pages/game/algorithm/wheel.js Visa fil

16
   const perAngle = Math.PI / cages.length;
16
   const perAngle = Math.PI / cages.length;
17
   
17
   
18
   // 摩天轮与轿厢旋转
18
   // 摩天轮与轿厢旋转
19
+  let _count = 0;
19
   let rotateAngle = 0;
20
   let rotateAngle = 0;
20
   const wheelRotate = () => {
21
   const wheelRotate = () => {
22
+    _count += 1;
21
     rotateAngle += rotateSpeed
23
     rotateAngle += rotateSpeed
22
     wheelArc.rotation = rotateAngle
24
     wheelArc.rotation = rotateAngle
23
     cages.forEach(cage => {
25
     cages.forEach(cage => {
34
 
36
 
35
   return {
37
   return {
36
     raduis,
38
     raduis,
37
-    rotate: () => two.addEventListener('update', wheelRotate),
39
+    rotate: () => {
40
+      console.log('----------START---------')
41
+      two.addEventListener('update', wheelRotate)
42
+      const t = setTimeout(() => {
43
+        console.log('----------1 MINUTES---------', _count)
44
+      }, 1000)
45
+    },
38
     stop: () => two.removeEventListener('update', wheelRotate),
46
     stop: () => two.removeEventListener('update', wheelRotate),
39
   }
47
   }
40
 }
48
 }