Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_game_select
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
NJ_game_select
Commits
0bc4dcd0
Commit
0bc4dcd0
authored
May 25, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 指读
parent
5507b240
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
9 deletions
+80
-9
NJ_game_select.ts
assets/NJ_game_select/scene/NJ_game_select.ts
+80
-9
No files found.
assets/NJ_game_select/scene/NJ_game_select.ts
View file @
0bc4dcd0
import
{
asyncCallNetworkApiGet
,
asyncDelay
,
buttonOnClick
,
jumpToCourseWare
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
resolve
}
from
"
dns
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -37,15 +38,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
circle
=
cc
.
find
(
'
Canvas/step1/pad/circle
'
);
circle
.
active
=
true
;
const
progress
=
cc
.
find
(
'
Canvas/step1/pad/circle/progress
'
);
await
this
.
asyncCountDown
(
progress
,
3
);
await
asyncDelay
(
0.3
);
await
this
.
checkPage
();
this
.
step
=
1
;
try
{
await
Promise
.
all
([
this
.
asyncCountDown
(
progress
,
3
),
this
.
checkPage
()
]);
this
.
step
=
1
;
}
catch
(
error
)
{
// TODO 三秒内没有检测到对应页码的后续处理; 先加个提示框
this
.
showTips
(
"
未检测到对应页面
"
);
}
}
async
startStep2
()
{
await
this
.
asyncPlayAudioByUrl
(
this
.
data
.
pageArr
[
this
.
currentPageIdx
].
hotZoneItemArr
[
this
.
currentPartIdx
].
audio_url
);
await
asyncDelay
(
0.3
);
await
this
.
checkPart
();
await
Promise
.
all
([
this
.
asyncPlayAudioByUrl
(
this
.
data
.
pageArr
[
this
.
currentPageIdx
].
hotZoneItemArr
[
this
.
currentPartIdx
].
audio_url
),
this
.
checkPart
()
]);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
...
...
@@ -61,12 +69,65 @@ export default class SceneComponent extends MyCocosSceneComponent {
jumpToCourseWare
(
this
.
rows
[
this
.
currentPartIdx
].
id
);
}
async
checkPage
()
{
checkPage
()
{
if
(
!
window
[
"
courseware
"
]){
// 没有中间层的话,直接判断为检测成功
return
true
;
}
// 定时三秒检测
const
timeout
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
reject
(
new
Error
(
'
checkpage timeout
'
)),
3000
)
});
const
pageId
=
this
.
data
.
pageArr
[
this
.
currentPageIdx
].
pageIdx
;
const
check
=
new
Promise
((
resolve
,
reject
)
=>
{
window
[
"
air
"
].
osmoFingerReadCallback
=
(
result
)
=>
{
const
resultObj
=
JSON
.
parse
(
result
);
if
(
resultObj
.
page_id
==
pageId
)
{
// 检测成功
window
[
"
courseware
"
].
closeOsmoFingerRead
();
resolve
();
}
};
window
[
"
courseware
"
].
openOsmoFingerRead
({
"
page_id
"
:
pageId
,
"
book_id
"
:
"
opw1
"
})
});
return
Promise
.
race
([
check
,
timeout
]);
}
async
checkPart
()
{
checkPart
()
{
if
(
!
window
[
"
courseware
"
]){
// 没有中间层的话,直接判断为检测成功
return
true
;
}
const
rect
=
this
.
data
.
pageArr
[
this
.
currentPageIdx
].
hotZoneItemArr
[
this
.
currentPartIdx
].
rect
;
const
checkInRegion
=
function
(
p
)
{
const
w
=
p
.
x
>
rect
.
x
&&
p
.
x
<
(
rect
.
x
+
rect
.
width
);
const
h
=
p
.
y
>
rect
.
y
&&
p
.
y
<
(
rect
.
y
+
rect
.
height
);
return
w
&&
h
;
};
const
pageId
=
this
.
data
.
pageArr
[
this
.
currentPageIdx
].
pageIdx
;
return
new
Promise
((
resolve
,
reject
)
=>
{
window
[
"
air
"
].
osmoFingerReadCallback
=
(
result
)
=>
{
const
resultObj
=
JSON
.
parse
(
result
);
const
p
=
resultObj
.
finger_pos_in_page
;
if
(
p
.
x
==
-
1
||
p
.
y
==
-
1
)
{
return
;
}
if
(
checkInRegion
(
p
))
{
// 检测成功
window
[
"
courseware
"
].
closeOsmoFingerRead
();
resolve
();
}
};
window
[
"
courseware
"
].
openOsmoFingerRead
({
"
page_id
"
:
pageId
,
"
book_id
"
:
"
opw1
"
})
});
}
folderId
:
any
;
...
...
@@ -151,6 +212,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
setNodeSpirteFrameByUrl
(
startBg
,
bgNode
);
}
showTips
(
tips
)
{
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
showTips
(
tips
);
}
else
{
console
.
log
(
tips
);
}
}
initListener
()
{
const
btn_return
=
cc
.
find
(
'
Canvas/btn_return
'
);
buttonOnClick
(
btn_return
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment