Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OP05
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
OP05
Commits
ee34caf6
Commit
ee34caf6
authored
Dec 06, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: setTimeout
parent
c3ba2f7c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
74 deletions
+91
-74
OP05.js
assets/OP05/scene/OP05.js
+53
-34
util.js
assets/OP05/script/util.js
+33
-36
utils.js
assets/OP05/script/utils.js
+5
-4
No files found.
assets/OP05/scene/OP05.js
View file @
ee34caf6
...
...
@@ -20,15 +20,16 @@ cc.Class({
this
.
initSize
();
},
showLog
(
str
)
{
showLog
(
str
)
{
const
node
=
cc
.
find
(
'
middleLayer
'
);
if
(
node
)
{
if
(
node
)
{
node
.
getComponent
(
'
middleLayer
'
).
showLog
(
str
);
}
else
{
}
else
{
cc
.
log
(
str
);
}
},
_timeoutIds
:
null
,
_imageResList
:
null
,
_audioResList
:
null
,
_animaResList
:
null
,
...
...
@@ -36,6 +37,7 @@ cc.Class({
this
.
_imageResList
=
[];
this
.
_audioResList
=
[];
this
.
_animaResList
=
[];
this
.
_timeoutIds
=
[];
},
_designSize
:
null
,
// 设计分辨率
...
...
@@ -257,18 +259,18 @@ cc.Class({
dragonDisplay
.
playAnimation
(
this
.
animationName
,
1
);
//animation所有的动画名称
icon_ex_txt
.
active
=
false
;
icon_ex
.
active
=
false
;
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
pg
.
view
.
visible
(
icon_ex
,
true
);
let
icon_ex_word
=
this
.
_stageData
.
word
;
this
.
wordAni
(
icon_ex_txt
,
icon_ex_word
)
pg
.
audio
.
playAudioByUrl
(
this
.
_stageData
.
sound
);
},
1000
*
2
);
setTimeout
(()
=>
{
},
1000
*
2
)
)
;
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
pg
.
view
.
visible
(
btn_record
,
true
);
pg
.
view
.
visible
(
btn_replay
,
true
);
this
.
playSFX
(
"
audio_record
"
);
},
1000
*
6.3
);
setTimeout
(()
=>
{
},
1000
*
6.3
)
)
;
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
pg
.
view
.
visible
(
icon_hand
,
true
);
let
action
=
cc
.
tween
(
icon_hand
);
action
.
sequence
(
...
...
@@ -276,7 +278,7 @@ cc.Class({
cc
.
tween
().
by
(
0.5
,
{
y
:
-
50
}),
).
repeatForever
();
action
.
start
();
},
1000
*
6.3
);
},
1000
*
6.3
)
)
;
}
else
if
(
GameManager
.
getIns
().
getState
()
==
2
)
{
pg
.
view
.
visible
(
icon_hand
,
false
);
pg
.
view
.
visible
(
btn_record
,
false
);
...
...
@@ -287,14 +289,14 @@ cc.Class({
pg
.
view
.
visible
(
btn_record
,
false
);
pg
.
view
.
visible
(
btn_recording
,
false
);
pg
.
view
.
visible
(
progress
,
false
);
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
//4秒钟之后出现goodjob提示
pg
.
view
.
visible
(
end
,
true
);
pg
.
view
.
visible
(
end_success
,
true
);
this
.
playSFX
(
"
audio_goodjob
"
);
},
1000
*
0.5
)
;
//4秒钟之后出现goodjob提示
setTimeout
(()
=>
{
},
1000
*
0.5
)
);
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
nextStage
();
},
1000
*
4
);
//6秒钟之后进入下一关卡
},
1000
*
4
)
)
;
//6秒钟之后进入下一关卡
}
else
if
(
GameManager
.
getIns
().
getState
()
==
4
)
{
// 一局失败弹出tryagain,同时下方录音按钮明亮并出现提示
pg
.
view
.
visible
(
end
,
true
);
...
...
@@ -303,7 +305,7 @@ cc.Class({
pg
.
view
.
visible
(
btn_record
,
true
);
pg
.
view
.
visible
(
progress
,
false
);
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
playSFX
(
"
audio_record
"
);
pg
.
view
.
visible
(
icon_hand
,
true
);
let
action
=
cc
.
tween
(
icon_hand
);
...
...
@@ -312,7 +314,7 @@ cc.Class({
cc
.
tween
().
by
(
0.5
,
{
y
:
-
50
}),
).
repeatForever
();
action
.
start
();
},
1000
*
1
);
},
1000
*
1
)
)
;
}
else
if
(
GameManager
.
getIns
().
getState
()
==
5
)
{
...
...
@@ -347,7 +349,7 @@ cc.Class({
itemfirst
.
y
=
17
;
itemfirst
.
getComponent
(
cc
.
RichText
).
string
=
strfirst1
;
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
let
times
=
20
;
let
time
=
0
;
let
inter
=
setInterval
(()
=>
{
...
...
@@ -361,7 +363,7 @@ cc.Class({
itemfirst
.
y
=
0
;
item
.
getComponent
(
cc
.
RichText
).
string
=
str2
;
},
30
);
},
4100
);
},
4100
)
)
;
// setTimeout(() => {
// //全部变大
// let str2 = `<size=150><color=#ffffff>${s0}</color><color=#0000>${s1}</color></size>`
...
...
@@ -381,7 +383,7 @@ cc.Class({
this
.
initLayout
()
window
.
courseware
&&
window
.
courseware
.
startTest
(
this
.
_stageData
.
word
);
//开始录音
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
if
(
!
window
.
courseware
)
return
this
.
recrodEnd
({
"
dtLastResponse
"
:
"
2021-09-17 13:36:26:109
"
,
"
refText
"
:
"
I haven't found anything out about him yet.
"
,
...
...
@@ -406,7 +408,7 @@ cc.Class({
data
=
JSON
.
parse
(
data
);
this
.
recrodEnd
(
data
);
});
//结束录音
},
4000
);
},
4000
)
)
;
},
recrodEnd
(
data
)
{
let
score
=
data
.
result
.
overall
;
...
...
@@ -486,9 +488,9 @@ cc.Class({
pg
.
view
.
visible
(
end
,
false
);
pg
.
view
.
visible
(
ant_ske
,
false
);
pg
.
view
.
visible
(
ax_ske
,
false
);
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
initStep2
();
},
2000
);
},
2000
)
)
;
},
initStep2
()
{
let
btn_replay
=
pg
.
view
.
find
(
this
,
"
btn_replay
"
)
...
...
@@ -654,9 +656,9 @@ cc.Class({
createStarAni
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
showStar
();
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
resolve
(
''
);
},
500
);
},
500
)
)
;
});
},
createFireworkAni
()
{
...
...
@@ -668,21 +670,30 @@ cc.Class({
showFireworks
(
cc
.
find
(
'
Canvas/firework_ani
'
),
cc
.
find
(
'
Canvas/RibbonNodeBase
'
).
children
,
cc
.
v2
(
0
,
-
400
),
cc
.
v2
(
0
,
1000
),
200
,
200
cc
.
v2
(
0
,
-
400
),
cc
.
v2
(
0
,
1000
),
200
,
200
,
(
id
)
=>
{
this
.
_timeoutIds
.
push
(
id
);
}
);
showFireworks
(
cc
.
find
(
'
Canvas/firework_ani
'
),
cc
.
find
(
'
Canvas/RibbonNodeBase
'
).
children
,
cc
.
v2
(
-
600
,
-
400
),
cc
.
v2
(
200
,
1000
),
200
,
200
cc
.
v2
(
-
600
,
-
400
),
cc
.
v2
(
200
,
1000
),
200
,
200
,
(
id
)
=>
{
this
.
_timeoutIds
.
push
(
id
);
}
);
showFireworks
(
cc
.
find
(
'
Canvas/firework_ani
'
),
cc
.
find
(
'
Canvas/RibbonNodeBase
'
).
children
,
cc
.
v2
(
600
,
-
400
),
cc
.
v2
(
-
200
,
1000
),
200
,
200
cc
.
v2
(
600
,
-
400
),
cc
.
v2
(
-
200
,
1000
),
200
,
200
,
(
id
)
=>
{
this
.
_timeoutIds
.
push
(
id
);
}
);
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
resolve
(
''
);
},
1000
);
},
1000
)
)
;
});
},
len
:
null
,
...
...
@@ -771,7 +782,9 @@ cc.Class({
async
showAllFirework
(
parentNode
,
nodeList
)
{
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
this
.
showFirework
(
cc
.
v2
(
0
,
-
parentNode
.
height
/
2
),
parentNode
,
nodeList
,
parentNode
.
width
*
2
/
3
,
parentNode
.
height
*
1.3
);
await
asyncDelay
(
0.1
);
await
asyncDelay
(
0.1
,
(
id
)
=>
{
this
.
_timeoutIds
.
push
(
id
);
});
}
},
...
...
@@ -834,4 +847,10 @@ cc.Class({
return
quadBase
;
},
// 生命周期
onDestroy
()
{
this
.
_timeoutIds
.
forEach
(
id
=>
{
clearTimeout
(
id
);
});
},
});
assets/OP05/script/util.js
View file @
ee34caf6
...
...
@@ -94,13 +94,13 @@ export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
}
}
export
function
getDistance
(
start
,
end
)
{
export
function
getDistance
(
start
,
end
)
{
var
pos
=
cc
.
v2
(
start
.
x
-
end
.
x
,
start
.
y
-
end
.
y
);
var
dis
=
Math
.
sqrt
(
pos
.
x
*
pos
.
x
+
pos
.
y
*
pos
.
y
);
var
dis
=
Math
.
sqrt
(
pos
.
x
*
pos
.
x
+
pos
.
y
*
pos
.
y
);
return
dis
;
}
export
function
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
export
function
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
...
...
@@ -114,21 +114,21 @@ export function playAudioByUrl(audio_url, cb=null) {
}
export
function
btnClickAnima
(
btn
,
time
=
0.15
,
rate
=
1.05
)
{
export
function
btnClickAnima
(
btn
,
time
=
0.15
,
rate
=
1.05
)
{
btn
.
tmpScale
=
btn
.
scale
;
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
scale
*
rate
})
.
to
(
time
/
2
,
{
scale
:
btn
.
scale
*
rate
})
.
start
()
})
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
()
=>
{
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
start
()
})
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
start
()
})
}
...
...
@@ -174,15 +174,12 @@ export function playAudio(audioClip, cb = null) {
}
}
export
async
function
asyncDelay
(
time
)
{
export
async
function
asyncDelay
(
time
,
func
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
setTimeout
(()
=>
{
const
id
=
setTimeout
(()
=>
{
resolve
();
},
time
*
1000
);
}
catch
(
e
)
{
reject
(
e
);
}
func
&&
func
(
id
);
})
}
...
...
assets/OP05/script/utils.js
View file @
ee34caf6
...
...
@@ -125,15 +125,16 @@ export async function jelly(node) {
});
}
export
async
function
asyncDelay
(
time
)
{
export
async
function
asyncDelay
(
time
,
func
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
const
id
=
setTimeout
(()
=>
{
resolve
();
},
time
*
1000
);
func
&&
func
(
id
);
})
}
export
async
function
showFireworks
(
baseNode
,
nodeList
,
pos
=
cc
.
v2
(
0
,
0
),
side
=
cc
.
v2
(
0
,
100
),
range
=
50
,
number
=
100
)
{
export
async
function
showFireworks
(
baseNode
,
nodeList
,
pos
=
cc
.
v2
(
0
,
0
),
side
=
cc
.
v2
(
0
,
100
),
range
=
50
,
number
=
100
,
func
)
{
new
Array
(
number
).
fill
(
'
'
).
forEach
(
async
(
_
,
i
)
=>
{
let
rabbonNode
=
new
cc
.
Node
();
...
...
@@ -165,7 +166,7 @@ export async function showFireworks(baseNode, nodeList, pos = cc.v2(0, 0), side
rabbonFall
(
rabbonNode
);
await
asyncDelay
(
Math
.
random
());
await
asyncDelay
(
Math
.
random
()
,
func
);
cc
.
tween
(
node
)
.
by
(
0.15
,
{
x
:
-
10
,
angle
:
-
10
})
.
by
(
0.3
,
{
x
:
20
,
angle
:
20
})
...
...
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