@shijiu/jsview-vue 0.9.783 → 0.9.804

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -1
  4. package/dom/target_core_revision.js +4 -4
  5. package/package.json +1 -1
  6. package/samples/Basic/components/anim/AnimTransition.vue +4 -4
  7. package/samples/DemoHomepage/router.js +5 -0
  8. package/samples/FilterDemo/VideoLayer.vue +2 -2
  9. package/samples/FocusBlockDemos/AutoFocus/App.vue +7 -2
  10. package/samples/FocusBlockDemos/AutoFocus/DialogContorls.js +5 -0
  11. package/samples/FocusBlockDemos/AutoFocus/PlaneBlock.vue +1 -1
  12. package/samples/FocusBlockDemos/ProgressiveFocusControl/App.vue +8 -2
  13. package/samples/GiftRain/App.vue +248 -0
  14. package/samples/GiftRain/audio/boom.mp3 +0 -0
  15. package/samples/GiftRain/audio/get.mp3 +0 -0
  16. package/samples/GiftRain/common/Sound.js +48 -0
  17. package/samples/GiftRain/components/RedPacket.vue +161 -0
  18. package/samples/GiftRain/components/Score.vue +55 -0
  19. package/samples/GiftRain/components/SpriteTranslate.vue +72 -0
  20. package/samples/GridDemo/Item.vue +1 -0
  21. package/samples/ImpactStop/App.vue +2 -2
  22. package/samples/Swiper/App.vue +1 -1
  23. package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +17 -1
  24. package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +15 -38
  25. package/utils/JsViewPlugin/JsvAudio/version.js +10 -10
  26. package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
  27. package/utils/JsViewVueTools/JsvTextTools.js +2 -0
  28. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +1 -1
  29. package/utils/JsViewVueWidget/JsvFilterView.vue +1 -1
  30. package/utils/JsViewVueWidget/JsvMarquee.vue +1 -1
  31. package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -1
  32. package/utils/JsViewVueWidget/JsvPosterDiv.vue +1 -1
  33. package/utils/JsViewVueWidget/JsvPosterImage.vue +1 -1
  34. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +43 -9
  35. package/utils/JsViewVueWidget/JsvTextBox.vue +1 -1
  36. package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +1 -1
@@ -3,11 +3,11 @@
3
3
  */
4
4
 
5
5
  const TargetRevision = {
6
- "CoreRevision": 1021277,
7
- "CoreRevisionAndBranch": "1021277",
8
- "JseRevision": "1.0.830",
6
+ "CoreRevision": 1021336,
7
+ "CoreRevisionAndBranch": "1021336",
8
+ "JseRevision": "1.0.882",
9
9
  "JseUrl":
10
- "http://cdn.release.qcast.cn/forge_js/master/JsViewES6_react_r830.jsv.9e271859.js"
10
+ "http://cdn.release.qcast.cn/forge_js/master/JsViewES6_react_r882.jsv.d4cae49e.js"
11
11
  };
12
12
 
13
13
  // 不要用export default,update-env脚本不能解析
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "./dom/*.js",
8
8
  "./loader/*.js"
9
9
  ],
10
- "version": "0.9.783",
10
+ "version": "0.9.804",
11
11
  "bin": {
12
12
  "jsview-post-build": "./scripts/jsview-post-build.js",
13
13
  "jsview-post-install": "./scripts/jsview-post-install.js",
@@ -105,7 +105,7 @@ onBeforeUnmount(() => {
105
105
  transformOrigin: state.transformOrigin,
106
106
  }"
107
107
  >
108
- 移动缩放旋转
108
+ {{"移动缩放旋转"}}
109
109
  </div>
110
110
  <div
111
111
  class="content-font"
@@ -117,7 +117,7 @@ onBeforeUnmount(() => {
117
117
  transform: state.transformTranslate,
118
118
  }"
119
119
  >
120
- 移动
120
+ {{"移动"}}
121
121
  </div>
122
122
  <div
123
123
  class="content-font"
@@ -130,7 +130,7 @@ onBeforeUnmount(() => {
130
130
  transform: state.transformScale,
131
131
  }"
132
132
  >
133
- 缩放
133
+ {{"缩放"}}
134
134
  </div>
135
135
  <div
136
136
  class="content-font"
@@ -143,7 +143,7 @@ onBeforeUnmount(() => {
143
143
  transform: state.transformRotate,
144
144
  }"
145
145
  >
146
- 旋转
146
+ {{"旋转"}}
147
147
  </div>
148
148
  </div>
149
149
  </div>
@@ -181,6 +181,11 @@ let routeList = [
181
181
  component: () =>
182
182
  import("jsview/samples/FocusBlockDemos/AutoFocus/App"),
183
183
  },
184
+ {
185
+ name:"红包雨",
186
+ path:"/feature/GiftRain",
187
+ component:()=>import("jsview/samples/GiftRain/App"),
188
+ }
184
189
  ];
185
190
 
186
191
  //添加MetroWidget demo
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { JsvVideo } from "jsview";
2
+ import JsvPlayer from "jsview/utils/JsViewPlugin/JsvPlayer";
3
3
 
4
4
  const props = defineProps({
5
5
  top: {
@@ -47,7 +47,7 @@ const video_url =
47
47
  animation: 'opacityVideoDemo_CompositeOpacity 3s infinite',
48
48
  }"
49
49
  >
50
- <jsv-video
50
+ <JsvPlayer
51
51
  :src="video_url"
52
52
  autoplay="autoplay"
53
53
  loop="loop"
@@ -15,11 +15,11 @@
15
15
 
16
16
 
17
17
  <script setup>
18
- import { shallowRef, watch, onMounted } from "vue"
18
+ import { shallowRef, watch, onMounted, onUnmounted } from "vue"
19
19
  import { useFocusHub, jJsvRuntimeBridge } from "jsview"
20
20
  import PlaneBlock from "./PlaneBlock.vue"
21
21
  import DialogBlock from "./DialogBlock.vue"
22
- import { CreateDialogControl } from "./DialogContorls.js"
22
+ import { CreateDialogControl, ReleaseDialogControl } from "./DialogContorls.js"
23
23
  import FocusNames from "./FocusNamesDefine.js"
24
24
 
25
25
  // 获取 FocusHub 操作句柄
@@ -37,6 +37,11 @@ watch(showDialog, ()=>{
37
37
  }
38
38
  })
39
39
 
40
+ onUnmounted(()=>{
41
+ // 退出时释放control全局引用
42
+ ReleaseDialogControl();
43
+ })
44
+
40
45
  onMounted(()=>{
41
46
  // 启动后先让主区域获得焦点
42
47
  focusHub.setFocus(FocusNames.MainPlane);
@@ -14,6 +14,10 @@ function CreateDialogControl(switcherRef) {
14
14
  return dialogConfigRef;
15
15
  }
16
16
 
17
+ function ReleaseDialogControl() {
18
+ dialogConfigRef = null;
19
+ }
20
+
17
21
  function ShowDialog(message) {
18
22
  if (dialogConfigRef) {
19
23
  console.log("通过showDialog开启对话框");
@@ -36,6 +40,7 @@ function GetDialogControl() {
36
40
 
37
41
  export {
38
42
  CreateDialogControl,
43
+ ReleaseDialogControl,
39
44
  ShowDialog,
40
45
  CloseDialog,
41
46
  GetDialogControl
@@ -38,7 +38,7 @@ const onKeyDownFunc = (ev)=>{
38
38
 
39
39
  const leftRightFunc = (action)=>{
40
40
  if (action == "left") {
41
- if (lastIndex >= 0) {
41
+ if (lastIndex > 0) {
42
42
  lastIndex--;
43
43
  console.log(`父节点 ${planeName} 收到left指令 切换子节点到"${ChildBlockNames[lastIndex]}`);
44
44
  focusHub.setFocus(ChildBlockNames[lastIndex]);
@@ -44,10 +44,16 @@ const onKeyDownFunc = (ev)=>{
44
44
  let keyConsumed = true;
45
45
  switch(ev.keyCode) {
46
46
  case DefaultKeyCodeMap.Up:
47
- focusHub.setFocus("UpPlane");
47
+ // 通过第二个参数 焦点pass to child,回避掉对焦点链上父节点设置focus会使使其子焦点失焦的问题
48
+ // pass to child功能:
49
+ // 1. 当子焦点在焦点链上时,对父节点进行setFocus操作,不会让子焦点失焦(不会抢子节点的焦点状态)
50
+ // 2. 当父节点从失焦状态,通过setFocus获焦时,若此父节点上一次失焦时,其子节点有焦点状态,
51
+ // 则此次父节点获焦也会让这个子焦点获焦
52
+ focusHub.setFocus("UpPlane", true);
48
53
  break;
49
54
  case DefaultKeyCodeMap.Down:
50
- focusHub.setFocus("DownPlane");
55
+ // 同UpPlane, 设置第二个参数 焦点pass to child, 回避掉对焦点链上父节点设置focus会使使其子焦点失焦的问题
56
+ focusHub.setFocus("DownPlane", true);
51
57
  break;
52
58
  default:
53
59
  keyConsumed = false;
@@ -0,0 +1,248 @@
1
+ <template>
2
+ <jsv-focus-block autoFocus ref="App" :onAction="actionDefines">
3
+ <div
4
+ :style="{ width: 1920, height: 1080, overflow: 'hidden', transform: 'scale3d(0.67,0.67,1)', left: -220 * 1.5 + 8, top: -170 - 8 }">
5
+ <JsvPreload :preloadList="preload_info"></JsvPreload>
6
+ <div
7
+ :style="{ backgroundImage: bg, width: 1920, height: 1080, overflow: 'hidden' }">
8
+ <Score :score="score"></Score>
9
+ <JsvActorMove key="JsvSpriteTranslate" :style="{
10
+ top: 476 * 1.5,
11
+ left: 220 * 1.5,
12
+ width: 194 * 1.5,
13
+ height: 244 * 1.5,
14
+ }" :control=_TranslateControl>
15
+ <div key="kimi" :style="{
16
+ top: 0,
17
+ left: 0,
18
+ width: 194 * 1.5,
19
+ height: 244 * 1.5,
20
+ backgroundImage: kimi,
21
+ }">
22
+ <div key="MoneyBag" ref="moneyBag" :style="{
23
+ top: 22 * 1.3,
24
+ left: 7,
25
+ width: 180 * 1.5,
26
+ height: 100 * 1.5,
27
+ backgroundColor: 'rgba(0,0,0,0)'
28
+ }"></div>
29
+ <div :style="{
30
+ top: 0,
31
+ left: 40 * 1.5,
32
+ width: 81 * 1.5,
33
+ height: 74 * 1.5,
34
+ visibility: scoreMinAnim !== null ? 'visible' : 'hidden',
35
+ backgroundImage: min_score_image,
36
+ animation: scoreMinAnim,
37
+ }" @animationend=_ScoreMinAnimationEnd />
38
+ <div :style="{
39
+ top: 0,
40
+ left: 40 * 1.5,
41
+ width: 81 * 1.5,
42
+ height: 74 * 1.5,
43
+ visibility: scoreAddAnim !== null ? 'visible' : 'hidden',
44
+ backgroundImage: add_score_image,
45
+ animation: scoreAddAnim,
46
+ }" @animationend=_ScoreAddAnimationEnd />
47
+ </div>
48
+ </JsvActorMove>
49
+ <RedPacket :MoneyBag="moneyBag" :onImpactTracer="_onImpactTracer" :_ScoreMinAnimationEnd="_ScoreMinAnimationEnd"
50
+ :_ScoreAddAnimationEnd="_ScoreAddAnimationEnd" />
51
+
52
+ </div>
53
+ <!-- 音频 -->
54
+ <JsvAudio key="AudioBg" :src="_AudioBgUrl" :loop="true" :onRef="onRef1" :onLoad="audioOnLoad" />
55
+
56
+ <JsvAudio v-if="!_DisableEffectSound" :onRef="onRef2" :loop="true" />
57
+
58
+
59
+ </div>
60
+ </jsv-focus-block>
61
+ </template>
62
+ <script setup>
63
+ /* eslint-disable */
64
+ import { JsvFocusBlock, JsvActorMove, JsvActorMoveControl, jJsvRuntimeBridge, JsvPreload, buildPreloadInfo } from "jsview";
65
+ import JsvAudio, { globalLoadJsvAudioPlugin } from "jsview/utils/JsViewPlugin/JsvAudio"
66
+ import { shallowRef, onMounted, onBeforeUnmount } from "vue";
67
+ import { useRouter } from "vue-router";
68
+ import Score from "./components/Score.vue";
69
+ import RedPacket from "./components/RedPacket.vue";
70
+ import Sound from "./common/Sound.js"
71
+ //音频Sound
72
+ const MySound = new Sound()
73
+ //加载音频插件 jsview/utils/JsViewPlugin/JsvAudio
74
+ globalLoadJsvAudioPlugin((status) => {
75
+ console.log("Audio plugin load status", status);
76
+ });
77
+ //预加载信息
78
+ const kimi_normal = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_normal.png';
79
+ const kimi_smile = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_smile.png';
80
+ const kimi_boom = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_boom.png';
81
+ const red_packet = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/red.png';
82
+ const bigRed_packet = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/bigred.png'
83
+ const boom_image = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/boom.png'
84
+ const bg = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/bg.jpg'
85
+ const preload_info = [
86
+ buildPreloadInfo(kimi_normal),
87
+ buildPreloadInfo(kimi_smile),
88
+ buildPreloadInfo(kimi_boom),
89
+ buildPreloadInfo(red_packet),
90
+ buildPreloadInfo(bigRed_packet),
91
+ buildPreloadInfo(boom_image),
92
+ buildPreloadInfo(bg)
93
+ ];
94
+ //定义不需要响应式的变量
95
+ let _CurrentRain = null;
96
+ //音频ref
97
+ let _Audio = null;
98
+ let _AudioBgUrl = "https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewAudio/MiniGameBackgroundMusic-redpack.mp3";
99
+ //背景音频ref
100
+ let _BgAudio = null;
101
+ let _IsRunning = false;
102
+ let _DisableEffectSound = true;
103
+ let _TranslateControl = new JsvActorMoveControl()
104
+ //定义需要响应式的变量
105
+ let kimi = shallowRef("http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_normal.png")
106
+ let score = shallowRef(0)
107
+ let min_score_image = shallowRef(null)
108
+ let add_score_image = shallowRef(null)
109
+ let scoreAddAnim = shallowRef(null)
110
+ let scoreMinAnim = shallowRef(null)
111
+ let moneyBag = shallowRef(null)
112
+
113
+ //定义扣分结束动画
114
+ const _ScoreAddAnimationEnd = (event) => {
115
+ // event.stopPropagation();
116
+ scoreAddAnim.value = null
117
+ console.log(" _ScoreAddAnimationEnd event:", event);
118
+ }
119
+ //定义加分结束动画
120
+ const _ScoreMinAnimationEnd = (event) => {
121
+ // event.stopPropagation();
122
+ scoreMinAnim.value = null
123
+ console.log(" _ScoreMinAnimationEnd event:", event);
124
+ }
125
+
126
+ //定义碰撞函数
127
+ const _onImpactTracer = (rain) => {
128
+ if (rain !== null && rain !== _CurrentRain) {
129
+ _CurrentRain = rain;
130
+ console.log("_onImpactTracer rain:", rain);
131
+ switch (rain.type) {
132
+ case 0:
133
+ scoreAddAnim.value = "scoreUp 0.2s";
134
+ kimi.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_normal.png";
135
+ add_score_image.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/add1.png";
136
+ score.value += 1;
137
+ MySound.playGetSound()
138
+ break;
139
+ case 1:
140
+ scoreAddAnim.value = "scoreUp 0.2s";
141
+ kimi.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_smile.png";
142
+ add_score_image.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/add5.png";
143
+ MySound.playGetSound()
144
+ score.value += 5;
145
+ break;
146
+ case 2:
147
+ scoreMinAnim.value = "scoreUp 0.2s";
148
+ min_score_image.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/min1.png";
149
+ kimi.value = "http://oss.image.qcast.cn/demo_images/red_packet_rain/kimi_boom.png";
150
+ score.value -= 1;
151
+ MySound.playBoomSound()
152
+ if (score.value < 0) {
153
+ score.value = 0;
154
+ }
155
+ break;
156
+ default:
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ //键盘松开时应该暂停动作
162
+ const onKeyUp = (ev) => {
163
+ console.log("onKeyUp in : ", ev);
164
+ if (ev.keyCode === 37 || ev.keyCode === 39) {
165
+ _IsRunning = false;
166
+ _TranslateControl.pause((x, y) => {
167
+ console.log(`_TranslateControl pause x:${x}`);
168
+ });
169
+ return true;
170
+ }
171
+
172
+ return false;
173
+ }
174
+ const router = useRouter();
175
+ //定义键盘按下
176
+ const onKeyDown = (ev) => {
177
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
178
+ router.go(-1)
179
+ } else if (ev.keyCode === 37) {
180
+ console.log(" ev.keyCode === 37 ");
181
+ if (!_IsRunning) {
182
+ _TranslateControl.moveToX(0, 400 * 1.5, null);
183
+ _IsRunning = true;
184
+ }
185
+ } else if (ev.keyCode === 39) {
186
+ console.log(" ev.keyCode === 39");
187
+ if (!_IsRunning) {
188
+ _TranslateControl.moveToX((1280 - 220 - 194) * 1.5, 400 * 1.5, null);
189
+ _IsRunning = true;
190
+ }
191
+ }
192
+ return true;
193
+ }
194
+
195
+ //注册
196
+ const actionDefines = {
197
+ onKeyDown,
198
+ onKeyUp
199
+ }
200
+ //定义音频回调
201
+ const onRef1 = (ref) => {
202
+ _BgAudio = ref
203
+ }
204
+ const onRef2 = (ref) => {
205
+ _Audio = ref
206
+ }
207
+ const audioOnLoad = () => {
208
+ console.log("audio on load")
209
+ _BgAudio.play()
210
+ }
211
+ onMounted(() => {
212
+ //初始化音效
213
+ MySound.initSound();
214
+ //摘画布
215
+ jJsvRuntimeBridge.notifyPageLoaded();
216
+ window.BgAudio = _BgAudio;
217
+ })
218
+
219
+ //卸载之前摧毁音效
220
+ onBeforeUnmount(() => {
221
+ MySound.destroy();
222
+ });
223
+ </script>
224
+
225
+ <style scoped>
226
+ @keyframes scoreUp {
227
+ from {
228
+ transform: translate3d(0, 0, 0);
229
+ }
230
+
231
+ to {
232
+ transform: translate3d(0, -20, 0);
233
+ }
234
+ }
235
+
236
+ @keyframes rainDown {
237
+ from {
238
+ transform: translate3d(0, -780, 0);
239
+ }
240
+
241
+ to {
242
+ transform: translate3d(0, 0, 0);
243
+ }
244
+ }
245
+
246
+ ;
247
+ ;
248
+ </style>
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ import { JsvSoundPool } from "jsview";
2
+ import getAudio from "../audio/get.mp3";
3
+ import boomAudio from "../audio/boom.mp3";
4
+
5
+ class Sound {
6
+ initSound() {
7
+ this.soundPool = new JsvSoundPool(10);
8
+ this.soundPool.request(
9
+ `url(${getAudio})`,
10
+ null,
11
+ 1,
12
+ (state, audioController) => {
13
+ console.log("load get audio ", state)
14
+ if (state === 0) {
15
+ Sound._AudioController1 = audioController;
16
+ }
17
+ }
18
+ );
19
+ this.soundPool.request(
20
+ `url(${boomAudio})`,
21
+ null,
22
+ 1,
23
+ (state, audioController) => {
24
+ console.log("load boom audio ", state)
25
+ if (state === 0) {
26
+ Sound._AudioController2 = audioController;
27
+ }
28
+ }
29
+ );
30
+ }
31
+
32
+ playGetSound() {
33
+ if (Sound._AudioController1) {
34
+ Sound._AudioController1.play();
35
+ }
36
+ }
37
+
38
+ playBoomSound() {
39
+ if (Sound._AudioController2) {
40
+ Sound._AudioController2.play();
41
+ }
42
+ }
43
+ destroy () {
44
+ this.soundPool.destroy()
45
+ }
46
+
47
+ }
48
+ export default Sound ;
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <div>
3
+ <div key="timer" :style="{
4
+ width: 140*1.5,
5
+ height: 140*1.5,
6
+ backgroundImage: _ScoreBg,
7
+ top: 40*1.5,
8
+ left: 40*1.5,
9
+ textAlign: 'center',
10
+ lineHeight: 140*1.5,
11
+ color: 'rgba(255,0,0,1.0)',
12
+ fontSize: 72*1.5
13
+ }">{{ timer }}</div>
14
+ <SpriteTranslate v-for="(item, index) in itemList" :MoneyBag="props.MoneyBag" :onImpactTracer="onImpactTracer"
15
+ :onDestory="_RemoveItem" :key="`spritetranslate${item.key}`" :item=item />
16
+ </div>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { shallowRef, defineProps, onMounted, onBeforeUnmount } from 'vue';
21
+ import SpriteTranslate from './SpriteTranslate.vue';
22
+ //定义props
23
+ const props = defineProps({
24
+ onImpactTracer: Function,
25
+ MoneyBag: Object,
26
+ _ScoreMinAnimationEnd:Function,
27
+ _ScoreAddAnimationEnd:Function
28
+ })
29
+ let _Index = 0;
30
+ // 随机生成列表
31
+ const _RedImage = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/red.png';
32
+ const _BigRedImage = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/bigred.png';
33
+ const _BoomImage = 'http://oss.image.qcast.cn/demo_images/red_packet_rain/boom.png';
34
+ const _ScoreBg = "http://oss.image.qcast.cn/demo_images/red_packet_rain/score_bg.png";
35
+ let itemList =shallowRef([])
36
+ let timer = shallowRef(60)
37
+ const onImpactTracer = props.onImpactTracer;
38
+ let _TimerOutId = null;
39
+ let _GameTimerID = null;
40
+ let _IsRunning = shallowRef(false);
41
+
42
+ //定义随机加入的item
43
+ const addRandomItemList = () => {
44
+ const total_num = 1;
45
+ let ret_obj = "";
46
+ for (let i = 0; i < total_num; i++) {
47
+ const random_index = Math.floor(Math.random() * 3);
48
+ const duration = 2 + Math.floor(Math.random() * 2);
49
+ const index = ++_Index;
50
+ const left = 300 * 1.5 + Math.floor(Math.random() * (1280 - 500) * 1.5);
51
+ const top = -20 * 1.5;
52
+
53
+ switch (random_index) {
54
+ case 0:
55
+ ret_obj = {
56
+ key: index.toString(), type: 0, src: _RedImage, left, top, width: 87, height: 118, duration,
57
+ };
58
+ break;
59
+ case 1:
60
+ ret_obj = {
61
+ key: index.toString(), type: 1, src: _BigRedImage, left, top, width: 210, height: 114, duration,
62
+ };
63
+ break;
64
+ case 2:
65
+ ret_obj = {
66
+ key: index.toString(), type: 2, src: _BoomImage, left, top, width: 100, height: 116, duration
67
+ };
68
+ break;
69
+ default:
70
+ break;
71
+ }
72
+
73
+ console.log("initRandomItemList ret_obj:", ret_obj);
74
+ itemList.value.push(ret_obj);
75
+ }
76
+ }
77
+ // addRandomItemList();
78
+
79
+
80
+
81
+ const startTimer = () => {
82
+ _TimerOutId = setInterval(() => {
83
+ console.log('timmmm', timer.value);
84
+ timer.value = timer.value - 1;
85
+ if (timer.value === 0) {
86
+ stopGame();
87
+ itemList.value = []
88
+ }
89
+ }, 1000);
90
+ }
91
+
92
+ const startGame = () => {
93
+ console.log("startGame ");
94
+ _IsRunning.value = true;
95
+ _Refresh();
96
+ }
97
+
98
+ const stopGame = () => {
99
+ console.log("stopGame ");
100
+ _IsRunning.value = false;
101
+ if (_TimerOutId !== null) {
102
+ clearInterval(_TimerOutId);
103
+ _TimerOutId = null;
104
+ }
105
+ //停止游戏时动画也应该停止
106
+ props._ScoreMinAnimationEnd()
107
+ props._ScoreAddAnimationEnd()
108
+ }
109
+
110
+ const _RemoveItem = (key) => {
111
+ console.log("_RemoveItem in itemList.length:", itemList.value.length);
112
+ for (let i = 0; i < itemList.value.length; i++) {
113
+ if (itemList.value[i].key === key) {
114
+ const item = itemList.value[i];
115
+ if (item.sensor) {
116
+ item.sensor.Recycle();
117
+ }
118
+ console.log("_RemoveItem key:", itemList.value[i].key);
119
+ itemList.value.splice(i, 1);
120
+ break;
121
+ }
122
+ }
123
+ console.log("_RemoveItem out itemList.length:", itemList.value.length);
124
+ }
125
+
126
+ const _Refresh = () => {
127
+ if (_IsRunning.value === false) {
128
+ return;
129
+ }
130
+ const delay = 500;// Math.floor(Math.random()*600);
131
+ _GameTimerID = setTimeout(() => {
132
+ if (_IsRunning.value === true) {
133
+ addRandomItemList();
134
+ _Refresh();
135
+ }
136
+ }, delay);
137
+ }
138
+
139
+
140
+ onMounted(() => {
141
+ console.log("render itemList.length:", itemList.value.length);
142
+ startGame();
143
+ startTimer();
144
+ })
145
+
146
+ onBeforeUnmount(() => {
147
+ if (_GameTimerID !== null) {
148
+ clearInterval(_GameTimerID);
149
+ _GameTimerID = null;
150
+ }
151
+
152
+ if (_TimerOutId !== null) {
153
+ clearInterval(_TimerOutId);
154
+ _TimerOutId = null;
155
+ }
156
+
157
+ stopGame();
158
+ })
159
+ </script>
160
+
161
+ <style scoped></style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div>
3
+ <div key="progress-container" :style="{
4
+ width: 40 * 1.5,
5
+ height: 400 * 1.5,
6
+ top: 200 * 1.5,
7
+ left: (40 + 70 - 20) * 1.5,
8
+ backgroundColor: 'rgba(255,255,255,0.2)'
9
+ }">
10
+ <div key="progress" :style="{
11
+ top: process_top * 1.5,
12
+ width: 40 * 1.5,
13
+ height: score_height * 1.5,
14
+ backgroundColor: '#ffd050'
15
+ }">
16
+ </div>
17
+ </div>
18
+ <div key="score" :style="{
19
+ width: 140 * 1.5,
20
+ height: 40 * 1.5,
21
+ color: '#ffd050',
22
+ fontSize: 24 * 1.5,
23
+ top: 620 * 1.5,
24
+ left: 40 * 1.5,
25
+ lineHeight: 40 * 1.5,
26
+ textOverflow: 'clip',
27
+ textAlign: 'center'
28
+ }">{{ `分数:${score}` }}</div>
29
+ </div>
30
+ </template>
31
+
32
+ <script setup type="text/javascript">
33
+ /* eslint-disable */
34
+ import { shallowRef, defineProps, watch} from 'vue';
35
+ //定义props
36
+ const props = defineProps({
37
+ score: Number
38
+ })
39
+ //定义得分
40
+ let score_height = shallowRef(0);
41
+ // let score = toRef(props, 'score');
42
+ let process_top = shallowRef(0)
43
+
44
+
45
+ //监听分数
46
+ watch(props, (n, o) => {
47
+ score_height.value = (props.score * 400 / 200)
48
+ if (score_height.value > 400) {
49
+ score_height.value = 400;
50
+ }
51
+ process_top.value = 400 - score_height.value;
52
+ })
53
+ </script>
54
+
55
+ <style scoped></style>