@shijiu/jsview-vue-samples 2.1.200 → 2.1.340-test.0
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.
- package/AnimPicture/App.vue +224 -120
- package/AnimPicture/Item.vue +44 -0
- package/ConnectLine/App.vue +173 -0
- package/CoupletsTest/App.vue +212 -0
- package/CoupletsTest/Common/SpriteDeal.js +30 -0
- package/CoupletsTest/LeadWire.vue +221 -0
- package/CoupletsTest/Maroon.vue +112 -0
- package/CoupletsTest/Salvo.vue +251 -0
- package/CoupletsTest/Sprite/firecracker.json +212 -0
- package/CoupletsTest/Sprite/firecracker.png +0 -0
- package/CoupletsTest/Sprite/fireworks.json +220 -0
- package/CoupletsTest/Sprite/fireworks.png +0 -0
- package/CoupletsTest/Sprite/scroll.json +76 -0
- package/CoupletsTest/Sprite/scroll.png +0 -0
- package/CoupletsTest/Sprite/spark.json +268 -0
- package/CoupletsTest/Sprite/spark.png +0 -0
- package/CoupletsTest/images/Couplets.png +0 -0
- package/CoupletsTest/images/goldencoin1.png +0 -0
- package/CoupletsTest/images/goldencoin2.png +0 -0
- package/CoupletsTest/images/leadWire.png +0 -0
- package/CoupletsTest/images/line.png +0 -0
- package/CoupletsTest/images/purpleStar.png +0 -0
- package/CoupletsTest/images/redStar.png +0 -0
- package/CoupletsTest/images/scroll1.png +0 -0
- package/CoupletsTest/images/star1.png +0 -0
- package/CoupletsTest/images/star2.png +0 -0
- package/CoupletsTest/images/star3.png +0 -0
- package/CoupletsTest/images/star4.png +0 -0
- package/CoupletsTest/images/yellowStar.png +0 -0
- package/DemoHomepage/components/BodyFrame.vue +27 -11
- package/DemoHomepage/router.js +35 -5
- package/DemoHomepage/views/Homepage.vue +1 -1
- package/DispersedItemSample/DispersedItemSample.vue +138 -0
- package/DispersedItemSample/DispersedItemWidget/DispersedItemWidget.vue +358 -0
- package/DispersedItemSample/DispersedItemWidget/MyRenderItem.ts +115 -0
- package/DispersedItemSample/Item.vue +55 -0
- package/FilterDemo/AnimatePic.vue +5 -6
- package/FocusMoveStyle/App.vue +126 -110
- package/FocusMoveStyle/CreepFocus.vue +128 -0
- package/FocusMoveStyle/FoldableItem.vue +279 -0
- package/FocusMoveStyle/Item.vue +32 -31
- package/FreeMove/App.vue +2 -2
- package/ImpactStop/App.vue +343 -384
- package/LatexDemo/App.vue +11 -0
- package/MetroWidgetDemos/RefreshDemo/App.vue +101 -0
- package/MetroWidgetDemos/RefreshDemo/Item.vue +116 -0
- package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +237 -0
- package/MetroWidgetDemos/RefreshDemo/data.js +16 -0
- package/MetroWidgetDemos/TripleWidget/App.vue +81 -0
- package/MetroWidgetDemos/TripleWidget/Item.vue +64 -0
- package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +93 -0
- package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +111 -0
- package/MetroWidgetDemos/routeList.js +12 -0
- package/ProgressBar/App.vue +128 -0
- package/QrcodeDemo/App.vue +2 -2
- package/SpriteImage/App.vue +113 -68
- package/SwiperTest/App.vue +105 -0
- package/ViewOpacity/App.vue +98 -0
- package/package.json +1 -1
package/ImpactStop/App.vue
CHANGED
|
@@ -1,50 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- 测试卡帧 -->
|
|
4
|
+
<div
|
|
5
|
+
class="test"
|
|
6
|
+
:style="{
|
|
7
|
+
animation: 'impact-stop-anim-rotate 1s infinite linear',
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
{{ "测试卡帧" }}
|
|
11
|
+
</div>
|
|
12
|
+
<jsv-focus-block autoFocus :onAction="onActionObj">
|
|
13
|
+
<div :style="{ width: 1280, height: 720, backgroundColor: '#000000' }">
|
|
14
|
+
<!-- 滑块 -->
|
|
15
|
+
<jsv-free-move-actor
|
|
16
|
+
ref="actorRef"
|
|
17
|
+
:top="520 - 30 + 1"
|
|
18
|
+
:left="40"
|
|
19
|
+
:width="30"
|
|
20
|
+
:height="30"
|
|
21
|
+
>
|
|
22
|
+
<div
|
|
23
|
+
:style="{
|
|
24
|
+
width: 30,
|
|
25
|
+
height: 30,
|
|
26
|
+
backgroundColor: actorColor,
|
|
27
|
+
}"
|
|
28
|
+
></div>
|
|
29
|
+
</jsv-free-move-actor>
|
|
30
|
+
|
|
31
|
+
<!-- 左边跳板 -->
|
|
32
|
+
<jsv-env-blocker
|
|
33
|
+
:top="520"
|
|
34
|
+
:left="40"
|
|
35
|
+
:width="400"
|
|
36
|
+
:height="5"
|
|
37
|
+
:topGID="1"
|
|
38
|
+
:bottomGID="2"
|
|
39
|
+
:leftGID="3"
|
|
40
|
+
:rightGID="4"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
:style="{
|
|
44
|
+
width: 400,
|
|
45
|
+
height: 5,
|
|
46
|
+
backgroundColor: 'rgba(255,255,0,1)',
|
|
47
|
+
}"
|
|
48
|
+
></div>
|
|
49
|
+
</jsv-env-blocker>
|
|
50
|
+
|
|
51
|
+
<!-- 中间跳板 -->
|
|
52
|
+
<jsv-env-blocker
|
|
53
|
+
:top="320"
|
|
54
|
+
:left="540"
|
|
55
|
+
:width="200"
|
|
56
|
+
:height="5"
|
|
57
|
+
:topGID="1"
|
|
58
|
+
:bottomGID="2"
|
|
59
|
+
:leftGID="3"
|
|
60
|
+
:rightGID="4"
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
:style="{
|
|
64
|
+
width: 200,
|
|
65
|
+
height: 5,
|
|
66
|
+
backgroundColor: 'rgba(255,255,0,1)',
|
|
67
|
+
}"
|
|
68
|
+
></div>
|
|
69
|
+
</jsv-env-blocker>
|
|
70
|
+
|
|
71
|
+
<!-- 右边跳板 -->
|
|
72
|
+
<jsv-env-blocker
|
|
73
|
+
:top="520"
|
|
74
|
+
:left="840"
|
|
75
|
+
:width="400"
|
|
76
|
+
:height="5"
|
|
77
|
+
:topGID="1"
|
|
78
|
+
:bottomGID="2"
|
|
79
|
+
:leftGID="3"
|
|
80
|
+
:rightGID="4"
|
|
81
|
+
>
|
|
82
|
+
<div
|
|
83
|
+
:style="{
|
|
84
|
+
width: 400,
|
|
85
|
+
height: 5,
|
|
86
|
+
backgroundColor: 'rgba(255,255,0,1)',
|
|
87
|
+
}"
|
|
88
|
+
></div>
|
|
89
|
+
</jsv-env-blocker>
|
|
90
|
+
|
|
91
|
+
<!-- 底板 -->
|
|
92
|
+
<jsv-env-blocker
|
|
93
|
+
:top="620"
|
|
94
|
+
:left="40"
|
|
95
|
+
:width="1200"
|
|
96
|
+
:height="5"
|
|
97
|
+
:topGID="1"
|
|
98
|
+
:bottomGID="2"
|
|
99
|
+
:leftGID="3"
|
|
100
|
+
:rightGID="4"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
:style="{
|
|
104
|
+
width: 1200,
|
|
105
|
+
height: 5,
|
|
106
|
+
backgroundColor: '#F0FFF0',
|
|
107
|
+
}"
|
|
108
|
+
></div>
|
|
109
|
+
</jsv-env-blocker>
|
|
110
|
+
|
|
111
|
+
<!-- 标题区域 -->
|
|
112
|
+
<div
|
|
113
|
+
:style="{
|
|
114
|
+
textAlign: 'center',
|
|
115
|
+
fontSize: 30,
|
|
116
|
+
lineHeight: 50,
|
|
117
|
+
color: '#ffffff',
|
|
118
|
+
left: 100,
|
|
119
|
+
top: 20,
|
|
120
|
+
width: 1280 - 200,
|
|
121
|
+
height: 50,
|
|
122
|
+
backgroundColor: 'rgba(27,38,151,0.8)',
|
|
123
|
+
}"
|
|
124
|
+
>
|
|
125
|
+
JsView环境下不会穿透模型
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<!-- 大多数设备的文字宽度时405, 但某些android 9.0设备上文字宽度是407 -->
|
|
129
|
+
<div
|
|
130
|
+
key="PrecisionGuideText"
|
|
131
|
+
class="text"
|
|
132
|
+
:style="{ top: 528, left: 40, width: 407, height: 40 }"
|
|
133
|
+
>
|
|
134
|
+
JSV下,立刻起跳会精确到边缘
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<!-- 提示文字 -->
|
|
138
|
+
<div
|
|
139
|
+
key="GuideText1"
|
|
140
|
+
class="text"
|
|
141
|
+
:style="{ top: 625, left: 370, width: 540, height: 40 }"
|
|
142
|
+
>
|
|
143
|
+
左右键调整跳跃起点,按OK键进行跳跃
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<!-- 方向提示 -->
|
|
147
|
+
<div
|
|
148
|
+
key="DirectText"
|
|
149
|
+
class="text"
|
|
150
|
+
:style="{ top: 150, left: 425, width: 430, height: 40 }"
|
|
151
|
+
>
|
|
152
|
+
{{ `当前方向:${direction > 0 ? "->" : "<-"}` }}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</jsv-focus-block>
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|
|
158
|
+
|
|
8
159
|
<script setup>
|
|
9
160
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
createImpactAutoFroze,
|
|
161
|
+
JsvFreeMoveActor,
|
|
162
|
+
FreeMoveDef,
|
|
163
|
+
JsvEnvBlocker,
|
|
164
|
+
FreeMoveFunc,
|
|
15
165
|
} from "jsview";
|
|
16
|
-
import { shallowRef, computed, onMounted
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const CONST_BOARD_LEFT = 0;
|
|
20
|
-
const CONST_BOARD_RIGHT = 1;
|
|
21
|
-
const CONST_BOARD_MID = 2;
|
|
22
|
-
|
|
23
|
-
const CONST_BOX_WIDTH = 30;
|
|
24
|
-
const CONST_BOX_HEIGHT = 30;
|
|
25
|
-
|
|
26
|
-
const horizontalControl = new JsvActorMoveControl();
|
|
27
|
-
const verticalControl = new JsvActorMoveControl();
|
|
28
|
-
|
|
29
|
-
const boxLeft = shallowRef(null);
|
|
30
|
-
const boxMid = shallowRef(null);
|
|
31
|
-
const boxRight = shallowRef(null);
|
|
32
|
-
const actor = shallowRef(null);
|
|
33
|
-
|
|
34
|
-
let actorVertical = shallowRef(null);
|
|
35
|
-
let actorHorizontal = shallowRef(null);
|
|
36
|
-
|
|
37
|
-
let viewsAutoFroze = null;
|
|
38
|
-
let sensorList = [];
|
|
39
|
-
let onBoard = CONST_BOARD_LEFT;
|
|
40
|
-
let keyPressed = false;
|
|
41
|
-
const actorState = {
|
|
42
|
-
jumping: false,
|
|
43
|
-
hMoving: false,
|
|
44
|
-
};
|
|
45
|
-
const showPrecisionGuild = shallowRef(true);
|
|
166
|
+
import { shallowRef, computed, onMounted } from "vue";
|
|
167
|
+
let actorControl = null;
|
|
168
|
+
let actorRef = shallowRef(null);
|
|
46
169
|
const direction = shallowRef(1);
|
|
47
170
|
const bodyState = shallowRef(0);
|
|
171
|
+
let board = "left";
|
|
172
|
+
let jumping = false;
|
|
173
|
+
const actEvents = FreeMoveDef.ActEventDefine;
|
|
48
174
|
|
|
49
175
|
const actorColor = computed(() => {
|
|
50
176
|
switch (bodyState.value) {
|
|
@@ -58,378 +184,211 @@ const actorColor = computed(() => {
|
|
|
58
184
|
return "#FFFFFF";
|
|
59
185
|
}
|
|
60
186
|
});
|
|
187
|
+
//键盘事件
|
|
188
|
+
const procKeyDown = (ev) => {
|
|
189
|
+
if (jumping) {
|
|
190
|
+
// 跳跃中,键盘锁定
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
switch (ev.keyCode) {
|
|
194
|
+
case 13:
|
|
195
|
+
jumping = true;
|
|
196
|
+
|
|
197
|
+
let interactNexus = FreeMoveFunc.newNexus();
|
|
198
|
+
|
|
199
|
+
actorControl.run([
|
|
200
|
+
actorControl.state().clearAllConditions(),
|
|
201
|
+
actorControl
|
|
202
|
+
.condition()
|
|
203
|
+
.onNextTick(1)
|
|
204
|
+
.then([
|
|
205
|
+
() => {
|
|
206
|
+
bodyState.value = 1;
|
|
207
|
+
},
|
|
208
|
+
actorControl
|
|
209
|
+
.condition()
|
|
210
|
+
.onHitBlock(1)
|
|
211
|
+
.then([
|
|
212
|
+
() => {
|
|
213
|
+
console.log("LudlDebug on hit 1");
|
|
214
|
+
bodyState.value = 0;
|
|
215
|
+
},
|
|
216
|
+
actorControl.state().revertWithHitBlock(),
|
|
217
|
+
actorControl.action().stopMoving(),
|
|
218
|
+
(a) => {
|
|
219
|
+
jumping = false;
|
|
220
|
+
|
|
221
|
+
console.log("LudlDebug on hit 1~", a);
|
|
222
|
+
|
|
223
|
+
if (a.yPos <= -200) {
|
|
224
|
+
board = "middle";
|
|
225
|
+
} else if (a.yPos <= 0) {
|
|
226
|
+
if (a.xPos < 440) {
|
|
227
|
+
board = "left";
|
|
228
|
+
direction.value = 1;
|
|
229
|
+
} else {
|
|
230
|
+
board = "right";
|
|
231
|
+
direction.value = 0;
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
reset();
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
]),
|
|
238
|
+
]),
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
if (direction.value) {
|
|
242
|
+
actorControl.run([
|
|
243
|
+
actorControl
|
|
244
|
+
.action(0, 0, interactNexus)
|
|
245
|
+
.setSpdAndAccel(7.9, -24, undefined, 1, null, () => {}),
|
|
246
|
+
actorControl
|
|
247
|
+
.condition()
|
|
248
|
+
.onNexusEvent(interactNexus, actEvents.SpeedRevertY)
|
|
249
|
+
.then([
|
|
250
|
+
() => {
|
|
251
|
+
bodyState.value = 2;
|
|
252
|
+
},
|
|
253
|
+
]),
|
|
254
|
+
]);
|
|
255
|
+
} else {
|
|
256
|
+
actorControl.run([
|
|
257
|
+
actorControl
|
|
258
|
+
.action(0, 0, interactNexus)
|
|
259
|
+
.setSpdAndAccel(-7.9, -24, undefined, 1, null, () => {}),
|
|
260
|
+
actorControl
|
|
261
|
+
.condition()
|
|
262
|
+
.onNexusEvent(interactNexus, actEvents.SpeedRevertY)
|
|
263
|
+
.then([
|
|
264
|
+
() => {
|
|
265
|
+
bodyState.value = 2;
|
|
266
|
+
},
|
|
267
|
+
]),
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
61
270
|
|
|
62
|
-
const onImpact = (impact_type) => {
|
|
63
|
-
// 根据碰撞层来调整滑块的状态(接触板信息)
|
|
64
|
-
console.log(`On impacted type=${impact_type}`);
|
|
65
|
-
bodyState.value = 0;
|
|
66
|
-
onBoard = impact_type;
|
|
67
|
-
switch (impact_type) {
|
|
68
|
-
case CONST_BOARD_MID:
|
|
69
|
-
verticalControl.jumpTo(0, -200); // jumpTo处理微小穿模的复位,-200为中间层和起始位置的高度差
|
|
70
|
-
horizontalControl.pause();
|
|
71
271
|
break;
|
|
72
|
-
case
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
272
|
+
case 37:
|
|
273
|
+
if (board == "left") {
|
|
274
|
+
actorControl.run([actorControl.action().setSpeed(-5, 0)]);
|
|
275
|
+
actorControl.run([
|
|
276
|
+
actorControl.state().clearAllConditions(),
|
|
277
|
+
actorControl
|
|
278
|
+
.condition()
|
|
279
|
+
.reachPosition(0, undefined)
|
|
280
|
+
.then([actorControl.action().stopMoving()]),
|
|
281
|
+
]);
|
|
282
|
+
} else if (board == "right") {
|
|
283
|
+
actorControl.run([actorControl.action().setSpeed(-5, 0)]);
|
|
284
|
+
actorControl.run([
|
|
285
|
+
actorControl.state().clearAllConditions(),
|
|
286
|
+
actorControl
|
|
287
|
+
.condition()
|
|
288
|
+
.reachPosition(840 - 40, undefined)
|
|
289
|
+
.then([actorControl.action().stopMoving()]),
|
|
290
|
+
]);
|
|
291
|
+
} else if (board == "middle") {
|
|
292
|
+
actorControl.run([actorControl.action().setSpeed(-5, 0)]);
|
|
293
|
+
actorControl.run([
|
|
294
|
+
actorControl.state().clearAllConditions(),
|
|
295
|
+
actorControl
|
|
296
|
+
.condition()
|
|
297
|
+
.reachPosition(540 - 40, undefined)
|
|
298
|
+
.then([actorControl.action().stopMoving()]),
|
|
299
|
+
]);
|
|
300
|
+
}
|
|
76
301
|
break;
|
|
77
|
-
case
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
302
|
+
case 39:
|
|
303
|
+
if (board == "left") {
|
|
304
|
+
actorControl.run([actorControl.action().setSpeed(5, 0)]);
|
|
305
|
+
actorControl.run([
|
|
306
|
+
actorControl.state().clearAllConditions(),
|
|
307
|
+
actorControl
|
|
308
|
+
.condition()
|
|
309
|
+
.reachPosition(410 - 40, undefined)
|
|
310
|
+
.then([actorControl.action().stopMoving()]),
|
|
311
|
+
]);
|
|
312
|
+
} else if (board == "right") {
|
|
313
|
+
actorControl.run([actorControl.action().setSpeed(5, 0)]);
|
|
314
|
+
actorControl.run([
|
|
315
|
+
actorControl.state().clearAllConditions(),
|
|
316
|
+
actorControl
|
|
317
|
+
.condition()
|
|
318
|
+
.reachPosition(1240 - 30 - 40, undefined)
|
|
319
|
+
.then([actorControl.action().stopMoving()]),
|
|
320
|
+
]);
|
|
321
|
+
} else if (board == "middle") {
|
|
322
|
+
actorControl.run([actorControl.action().setSpeed(5, 0)]);
|
|
323
|
+
actorControl.run([
|
|
324
|
+
actorControl.state().clearAllConditions(),
|
|
325
|
+
actorControl
|
|
326
|
+
.condition()
|
|
327
|
+
.reachPosition(740 - 40 - 30, undefined)
|
|
328
|
+
.then([actorControl.action().stopMoving()]),
|
|
329
|
+
]);
|
|
330
|
+
}
|
|
83
331
|
break;
|
|
84
332
|
}
|
|
85
|
-
actorState.jumping = false;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const onLanding = () => {
|
|
89
|
-
// 滑块未与左中右任何一个板发生碰撞,落在了地板的时候
|
|
90
|
-
console.log("On landing");
|
|
91
|
-
bodyState.value = 0;
|
|
92
|
-
actorState.jumping = false;
|
|
93
|
-
reset();
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const reset = () => {
|
|
97
|
-
console.log("On reset");
|
|
98
|
-
// 将两个运动都停止后再进行jumpTo,以保证两个jumpTo动作在同一帧完成
|
|
99
|
-
verticalControl.pause(() => {
|
|
100
|
-
horizontalControl.pause(() => {
|
|
101
|
-
verticalControl.jumpTo(0, 0);
|
|
102
|
-
horizontalControl.jumpTo(0, 0);
|
|
103
|
-
onBoard = CONST_BOARD_LEFT;
|
|
104
|
-
showPrecisionGuild.value = true;
|
|
105
|
-
direction.value = 1;
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
333
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
112
|
-
router?.go(-1); // 有router时,是从DemoHomepage进入,回退
|
|
113
|
-
}
|
|
114
|
-
if (actorState.jumping) {
|
|
334
|
+
const procKeyUp = (ev) => {
|
|
335
|
+
if (jumping) {
|
|
115
336
|
// 跳跃中,键盘锁定
|
|
116
337
|
return true;
|
|
117
338
|
}
|
|
339
|
+
switch (ev.keyCode) {
|
|
340
|
+
case 37:
|
|
341
|
+
actorControl.run([actorControl.action().stopMoving()]);
|
|
342
|
+
break;
|
|
343
|
+
case 39:
|
|
344
|
+
actorControl.run([actorControl.action().stopMoving()]);
|
|
345
|
+
break;
|
|
118
346
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 控制按键按下时,键盘锁定
|
|
125
|
-
keyPressed = true;
|
|
126
|
-
|
|
127
|
-
// 滑块位置可能发生变更,所以消除动画精度测试的描素文字
|
|
128
|
-
if (showPrecisionGuild.value) {
|
|
129
|
-
showPrecisionGuild.value = false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (ev.keyCode === 13) {
|
|
133
|
-
// 滑块跳跃(纵向和横向的配置值都是计算过的,为了进行第一跳的精度测试)
|
|
134
|
-
actorState.jumping = true;
|
|
135
|
-
// 垂直方向抛物运动
|
|
136
|
-
bodyState.value = 1;
|
|
137
|
-
verticalControl.throwAlongY(
|
|
138
|
-
-1000,
|
|
139
|
-
2450,
|
|
140
|
-
{ type: "catch", position: 100, direction: 1 },
|
|
141
|
-
() => {
|
|
142
|
-
onLanding();
|
|
143
|
-
}, // 未碰撞落地时,对滑块位置进行重置
|
|
144
|
-
() => {
|
|
145
|
-
bodyState.value = 2;
|
|
146
|
-
} // 调整成落下状态
|
|
147
|
-
);
|
|
148
|
-
// 水平方向,按照direction的值,移动到屏幕两端
|
|
149
|
-
if (direction.value > 0) {
|
|
150
|
-
horizontalControl.moveToX(1200 - CONST_BOX_WIDTH, 400, null);
|
|
151
|
-
} else {
|
|
152
|
-
horizontalControl.moveToX(0, 400, null);
|
|
153
|
-
}
|
|
154
|
-
} else if (ev.keyCode === 37) {
|
|
155
|
-
// 滑块向左移动
|
|
156
|
-
actorState.hMoving = true;
|
|
157
|
-
// 分三个区域设定移动范围
|
|
158
|
-
let target_x = 0;
|
|
159
|
-
if (onBoard === CONST_BOARD_LEFT) {
|
|
160
|
-
target_x = 0;
|
|
161
|
-
} else if (onBoard === CONST_BOARD_MID) {
|
|
162
|
-
target_x = 500;
|
|
163
|
-
} else if (onBoard === CONST_BOARD_RIGHT) {
|
|
164
|
-
target_x = 800;
|
|
165
|
-
}
|
|
166
|
-
horizontalControl.moveToX(target_x, 300, null);
|
|
167
|
-
} else if (ev.keyCode === 39) {
|
|
168
|
-
// 滑块向右移动
|
|
169
|
-
actorState.hMoving = true;
|
|
170
|
-
// 分三个区域设定移动范围
|
|
171
|
-
let target_x = 0;
|
|
172
|
-
if (onBoard === CONST_BOARD_LEFT) {
|
|
173
|
-
target_x = 396 - CONST_BOX_WIDTH;
|
|
174
|
-
} else if (onBoard === CONST_BOARD_MID) {
|
|
175
|
-
target_x = 699 - CONST_BOX_WIDTH;
|
|
176
|
-
} else if (onBoard === CONST_BOARD_RIGHT) {
|
|
177
|
-
target_x = 1199 - CONST_BOX_WIDTH;
|
|
178
|
-
}
|
|
179
|
-
horizontalControl.moveToX(target_x, 350, null);
|
|
347
|
+
default:
|
|
348
|
+
break;
|
|
180
349
|
}
|
|
181
|
-
return true;
|
|
182
350
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (actorState.hMoving) {
|
|
188
|
-
// 停止用户通过左右键发起的水平移动
|
|
189
|
-
horizontalControl.pause(null);
|
|
190
|
-
actorState.hMoving = false;
|
|
191
|
-
}
|
|
351
|
+
const onActionObj = {
|
|
352
|
+
onKeyDown: procKeyDown,
|
|
353
|
+
onKeyUp: procKeyUp,
|
|
192
354
|
};
|
|
193
355
|
|
|
356
|
+
//掉到最下面一层的地板则重新定位
|
|
357
|
+
const reset = () => {
|
|
358
|
+
board = "left";
|
|
359
|
+
direction.value = 1;
|
|
360
|
+
actorControl.run([actorControl.action().teleportTo(0, 0)]);
|
|
361
|
+
};
|
|
194
362
|
onMounted(() => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/* 将碰撞发生后要停止动画的元素打包 */
|
|
198
|
-
viewsAutoFroze = createImpactAutoFroze(
|
|
199
|
-
[actorVertical.value.mainDiv, actorHorizontal.value.mainDiv],
|
|
200
|
-
null
|
|
201
|
-
); // 此句柄最好保留,未来可以通过此句柄统一进行views list更新
|
|
202
|
-
|
|
203
|
-
/* 构建左边碰撞区 */
|
|
204
|
-
sensorList.push(
|
|
205
|
-
createImpactTracer(
|
|
206
|
-
actor.value,
|
|
207
|
-
boxLeft.value,
|
|
208
|
-
createImpactCallback(() => {
|
|
209
|
-
onImpact(CONST_BOARD_LEFT);
|
|
210
|
-
}, null),
|
|
211
|
-
viewsAutoFroze
|
|
212
|
-
)
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
/* 构建中间碰撞区 */
|
|
216
|
-
sensorList.push(
|
|
217
|
-
createImpactTracer(
|
|
218
|
-
actor.value,
|
|
219
|
-
boxMid.value,
|
|
220
|
-
createImpactCallback(() => {
|
|
221
|
-
onImpact(CONST_BOARD_MID);
|
|
222
|
-
}, null),
|
|
223
|
-
viewsAutoFroze
|
|
224
|
-
)
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
/* 构建右边碰撞区 */
|
|
228
|
-
sensorList.push(
|
|
229
|
-
createImpactTracer(
|
|
230
|
-
actor.value,
|
|
231
|
-
boxRight.value,
|
|
232
|
-
createImpactCallback(() => {
|
|
233
|
-
onImpact(CONST_BOARD_RIGHT);
|
|
234
|
-
}, null),
|
|
235
|
-
viewsAutoFroze
|
|
236
|
-
)
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
reset();
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
onBeforeUnmount(() => {
|
|
243
|
-
/* 重要! 退出后应该释放所有碰撞监听者 */
|
|
244
|
-
for (const sensor of sensorList) {
|
|
245
|
-
sensor.Recycle();
|
|
246
|
-
}
|
|
247
|
-
viewsAutoFroze?.Recycle();
|
|
363
|
+
actorControl = actorRef.value.control;
|
|
248
364
|
});
|
|
249
365
|
</script>
|
|
250
366
|
|
|
251
|
-
<template>
|
|
252
|
-
<jsv-focus-block
|
|
253
|
-
autoFocus
|
|
254
|
-
:onAction="{
|
|
255
|
-
onKeyDown,
|
|
256
|
-
onKeyUp,
|
|
257
|
-
}"
|
|
258
|
-
:style="{ width: 1280, height: 720, backgroundColor: '#000000' }"
|
|
259
|
-
>
|
|
260
|
-
<div
|
|
261
|
-
:style="{
|
|
262
|
-
textAlign: 'center',
|
|
263
|
-
fontSize: 30,
|
|
264
|
-
lineHeight: 50,
|
|
265
|
-
color: '#ffffff',
|
|
266
|
-
left: 100,
|
|
267
|
-
top: 20,
|
|
268
|
-
width: 1280 - 200,
|
|
269
|
-
height: 50,
|
|
270
|
-
backgroundColor: 'rgba(27,38,151,0.8)',
|
|
271
|
-
}"
|
|
272
|
-
>
|
|
273
|
-
JsView环境下不会穿透模型(PC上会穿模)
|
|
274
|
-
</div>
|
|
275
|
-
|
|
276
|
-
<div
|
|
277
|
-
key="bottomWall"
|
|
278
|
-
:style="{
|
|
279
|
-
top: 620,
|
|
280
|
-
left: 40,
|
|
281
|
-
width: 1200,
|
|
282
|
-
height: 5,
|
|
283
|
-
backgroundColor: '#F0FFF0',
|
|
284
|
-
}"
|
|
285
|
-
/>
|
|
286
|
-
|
|
287
|
-
<div
|
|
288
|
-
key="leftFloor"
|
|
289
|
-
:style="{
|
|
290
|
-
top: 520,
|
|
291
|
-
left: 40,
|
|
292
|
-
width: 397,
|
|
293
|
-
height: 5,
|
|
294
|
-
backgroundColor: '#F0F000',
|
|
295
|
-
}"
|
|
296
|
-
/>
|
|
297
|
-
|
|
298
|
-
<!-- 碰撞体的高度要比每帧移动距离大,因为碰撞判断是每帧内进行判断,并不连续,距离太小可能穿模 -->
|
|
299
|
-
|
|
300
|
-
<div
|
|
301
|
-
key="leftFloorImp"
|
|
302
|
-
ref="boxLeft"
|
|
303
|
-
:style="{
|
|
304
|
-
top: 520,
|
|
305
|
-
left: 40,
|
|
306
|
-
width: 397,
|
|
307
|
-
height: 15,
|
|
308
|
-
backgroundColor: 'rgba(255,255,255,0.2)',
|
|
309
|
-
}"
|
|
310
|
-
/>
|
|
311
|
-
|
|
312
|
-
<div
|
|
313
|
-
key="midFloor"
|
|
314
|
-
:style="{
|
|
315
|
-
top: 320,
|
|
316
|
-
left: 540,
|
|
317
|
-
width: 200,
|
|
318
|
-
height: 5,
|
|
319
|
-
backgroundColor: '#F0F000',
|
|
320
|
-
}"
|
|
321
|
-
/>
|
|
322
|
-
<div
|
|
323
|
-
key="midFloorImp"
|
|
324
|
-
ref="boxMid"
|
|
325
|
-
:style="{
|
|
326
|
-
top: 320,
|
|
327
|
-
left: 540,
|
|
328
|
-
width: 200,
|
|
329
|
-
height: 15,
|
|
330
|
-
backgroundColor: 'rgba(0,0,0,0)',
|
|
331
|
-
}"
|
|
332
|
-
/>
|
|
333
|
-
|
|
334
|
-
<div
|
|
335
|
-
key="rightFloor"
|
|
336
|
-
:style="{
|
|
337
|
-
top: 520,
|
|
338
|
-
left: 840,
|
|
339
|
-
width: 400,
|
|
340
|
-
height: 5,
|
|
341
|
-
backgroundColor: '#F0F000',
|
|
342
|
-
}"
|
|
343
|
-
/>
|
|
344
|
-
<div
|
|
345
|
-
key="rightFloorImp"
|
|
346
|
-
ref="boxRight"
|
|
347
|
-
:style="{
|
|
348
|
-
top: 520,
|
|
349
|
-
left: 820,
|
|
350
|
-
width: 400,
|
|
351
|
-
height: 15,
|
|
352
|
-
backgroundColor: 'rgba(0,0,0,0)',
|
|
353
|
-
}"
|
|
354
|
-
/>
|
|
355
|
-
|
|
356
|
-
<!-- 大多数设备的文字宽度时405, 但某些android 9.0设备上文字宽度是407 -->
|
|
357
|
-
<div
|
|
358
|
-
v-if="showPrecisionGuild"
|
|
359
|
-
key="PrecisionGuideText"
|
|
360
|
-
class="text"
|
|
361
|
-
:style="{ top: 528, left: 40, width: 407, height: 40 }"
|
|
362
|
-
>
|
|
363
|
-
JSV下,立刻起跳会精确到边缘
|
|
364
|
-
</div>
|
|
365
|
-
|
|
366
|
-
<div
|
|
367
|
-
key="GuideText1"
|
|
368
|
-
class="text"
|
|
369
|
-
:style="{ top: 625, left: 370, width: 540, height: 40 }"
|
|
370
|
-
>
|
|
371
|
-
左右键调整跳跃起点,按OK键进行跳跃
|
|
372
|
-
</div>
|
|
373
|
-
<div
|
|
374
|
-
key="DirectText"
|
|
375
|
-
class="text"
|
|
376
|
-
:style="{ top: 150, left: 425, width: 430, height: 40 }"
|
|
377
|
-
>
|
|
378
|
-
{{ `当前方向:${direction > 0 ? "->" : "<-"}` }}
|
|
379
|
-
</div>
|
|
380
|
-
|
|
381
|
-
<div key="actor" :style="{ top: 520 - CONST_BOX_HEIGHT - 2, left: 40 }">
|
|
382
|
-
<jsv-actor-move
|
|
383
|
-
key="horizontal"
|
|
384
|
-
ref="actorHorizontal"
|
|
385
|
-
:control="horizontalControl"
|
|
386
|
-
>
|
|
387
|
-
<jsv-actor-move
|
|
388
|
-
key="vertical"
|
|
389
|
-
ref="actorVertical"
|
|
390
|
-
:control="verticalControl"
|
|
391
|
-
>
|
|
392
|
-
<div
|
|
393
|
-
ref="actor"
|
|
394
|
-
:style="{
|
|
395
|
-
backgroundColor: actorColor,
|
|
396
|
-
width: CONST_BOX_WIDTH,
|
|
397
|
-
height: CONST_BOX_HEIGHT,
|
|
398
|
-
}"
|
|
399
|
-
></div>
|
|
400
|
-
</jsv-actor-move>
|
|
401
|
-
</jsv-actor-move>
|
|
402
|
-
</div>
|
|
403
|
-
|
|
404
|
-
<!-- 一个无限动画元素,来测试卡顿 -->
|
|
405
|
-
<div
|
|
406
|
-
:style="{
|
|
407
|
-
top: 100,
|
|
408
|
-
left: 50,
|
|
409
|
-
height: 150,
|
|
410
|
-
width: 150,
|
|
411
|
-
backgroundColor: '#334455',
|
|
412
|
-
animation: 'impact-stop-anim-rotate 1s infinite linear',
|
|
413
|
-
}"
|
|
414
|
-
/>
|
|
415
|
-
</jsv-focus-block>
|
|
416
|
-
</template>
|
|
417
|
-
|
|
418
367
|
<style scoped>
|
|
368
|
+
.test {
|
|
369
|
+
top: 100;
|
|
370
|
+
left: 50;
|
|
371
|
+
height: 150;
|
|
372
|
+
width: 150;
|
|
373
|
+
background-color: #334455;
|
|
374
|
+
text-align: center;
|
|
375
|
+
line-height: 150;
|
|
376
|
+
font-size: 30;
|
|
377
|
+
color: #ffffff;
|
|
378
|
+
z-index: 999;
|
|
379
|
+
}
|
|
419
380
|
@keyframes impact-stop-anim-rotate {
|
|
420
381
|
from {
|
|
421
|
-
transform: rotate3d(0, 0, 1,
|
|
382
|
+
transform: rotate3d(0, 0, 1, 360deg);
|
|
422
383
|
}
|
|
423
384
|
to {
|
|
424
385
|
transform: rotate3d(0, 0, 1, 0deg);
|
|
425
386
|
}
|
|
426
387
|
}
|
|
427
|
-
|
|
428
388
|
.text {
|
|
429
389
|
font-size: 30;
|
|
430
390
|
color: #73665c;
|
|
431
391
|
line-height: 40;
|
|
432
|
-
overflow: hidden;
|
|
433
392
|
white-space: nowrap;
|
|
434
393
|
text-overflow: ellipsis;
|
|
435
394
|
text-align: center;
|