Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Sbx_Pronunciation
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
Sbx_Pronunciation
Commits
4c1a0b98
Commit
4c1a0b98
authored
Dec 19, 2021
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 定时器释放
parent
9858b172
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
Sbx_Pronunciation.js
assets/Sbx_Pronunciation/scene/Sbx_Pronunciation.js
+2
-0
Cartoon.js
assets/Sbx_Pronunciation/script/Cartoon.js
+13
-2
GameLogic.js
assets/Sbx_Pronunciation/script/GameLogic.js
+16
-4
No files found.
assets/Sbx_Pronunciation/scene/Sbx_Pronunciation.js
View file @
4c1a0b98
...
...
@@ -88,6 +88,8 @@ cc.Class({
onDestory
()
{
cc
.
audioEngine
.
stopAll
()
this
.
gameLogic
.
destroy
()
},
getData
(
func
)
{
...
...
assets/Sbx_Pronunciation/script/Cartoon.js
View file @
4c1a0b98
...
...
@@ -174,13 +174,24 @@ export default class Cartoon {
}
}
_timeoutIds
=
[]
_intervalIds
=
[]
destroy
()
{
this
.
_timeoutIds
.
forEach
(
id
=>
{
clearTimeout
(
id
);
});
this
.
_intervalIds
.
forEach
(
id
=>
{
clearInterval
(
id
);
});
}
playVideo
(
videoPlayer
,
callback
)
{
if
(
videoPlayer
&&
videoPlayer
.
isPlaying
)
{
videoPlayer
.
stop
()
}
if
(
videoPlayer
)
{
setTimeout
(()
=>
{
this
.
_timeoutIds
(
setTimeout
(()
=>
{
videoPlayer
.
play
()
videoPlayer
.
node
.
off
(
"
completed
"
)
videoPlayer
.
node
.
on
(
"
completed
"
,
()
=>
{
...
...
@@ -188,7 +199,7 @@ export default class Cartoon {
callback
()
}
})
},
50
)
},
50
)
)
}
}
...
...
assets/Sbx_Pronunciation/script/GameLogic.js
View file @
4c1a0b98
...
...
@@ -452,16 +452,16 @@ export default class GameLogic {
if
(
this
.
m_currentQuestion
>=
this
.
g_formData
.
dataArray
.
length
)
{
this
.
m_currentQuestion
=
this
.
g_formData
.
dataArray
.
length
-
1
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
this
.
_timeoutIds
(
setTimeout
(()
=>
{
resolve
(
false
)
},
20
);
},
20
)
)
;
});
}
else
if
(
this
.
m_currentQuestion
<=
-
1
)
{
this
.
m_currentQuestion
=
0
;
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
this
.
_timeoutIds
(
setTimeout
(()
=>
{
resolve
(
false
)
},
20
);
},
20
)
)
;
});
}
...
...
@@ -720,4 +720,16 @@ export default class GameLogic {
console
.
log
(
`Click enabled! [
${
eventName
}
]`
)
}
_timeoutIds
=
[]
_intervalIds
=
[]
destroy
()
{
this
.
g_cartoon
.
destroy
();
this
.
_timeoutIds
.
forEach
(
id
=>
{
clearTimeout
(
id
);
});
this
.
_intervalIds
.
forEach
(
id
=>
{
clearInterval
(
id
);
});
}
}
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