Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dc_NS_04
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
dc_NS_04
Commits
5c29605e
Commit
5c29605e
authored
Mar 23, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 自动录音
parent
fda22160
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
119 deletions
+32
-119
dc_NS_04.fire
assets/dc_NS_04/scene/dc_NS_04.fire
+1
-1
dc_NS_04.ts
assets/dc_NS_04/scene/dc_NS_04.ts
+31
-118
No files found.
assets/dc_NS_04/scene/dc_NS_04.fire
View file @
5c29605e
...
...
@@ -1983,7 +1983,7 @@
"__id__": 40
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 47
...
...
assets/dc_NS_04/scene/dc_NS_04.ts
View file @
5c29605e
...
...
@@ -29,7 +29,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
_status
=
{
currentTipAudioId
:
null
,
canClick
:
true
,
currentSelectedCard
:
null
,
tryAgainFlg
:
false
,
...
...
@@ -177,9 +176,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
cc
.
find
(
'
Canvas/mask
'
).
active
)
{
return
;
}
this
.
playLocalAudio
(
'
tips
'
,
(
id
)
=>
{
this
.
_status
.
currentTipAudioId
=
id
;
});
await
this
.
userSpeak
();
await
this
.
hideCards
(
card
,
this
.
_status
.
currentSelectedCard
);
this
.
checkQuestionOver
();
...
...
@@ -326,7 +322,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
mask
.
active
=
false
;
this
.
_status
=
{
canClick
:
true
,
currentTipAudioId
:
null
,
currentSelectedCard
:
null
,
tryAgainFlg
:
false
,
starLength
:
0
,
...
...
@@ -370,120 +365,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
userSpeak
()
{
async
userSpeak
()
{
const
word
=
this
.
_status
.
currentSelectedCard
[
'
word
'
];
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
'
userSpeak:
'
+
word
);
const
baseSpeaker
=
cc
.
find
(
'
Canvas/bg/speaker
'
);
baseSpeaker
.
active
=
true
;
const
bg
=
baseSpeaker
.
getChildByName
(
'
bg
'
);
cc
.
tween
(
bg
)
.
set
({
opacity
:
0
})
.
to
(
0.5
,
{
opacity
:
100
})
.
start
();
const
speaker
=
baseSpeaker
.
getChildByName
(
'
speaker
'
);
const
btnStart
=
baseSpeaker
.
getChildByName
(
'
btnStart
'
);
const
btnStop
=
baseSpeaker
.
getChildByName
(
'
btnStop
'
);
btnStart
.
active
=
true
;
btnStart
[
'
canClick
'
]
=
true
;
btnStart
.
off
(
'
click
'
);
btnStart
.
on
(
'
click
'
,
()
=>
{
if
(
typeof
(
this
.
_status
.
currentTipAudioId
)
==
'
number
'
)
{
cc
.
audioEngine
.
stop
(
this
.
_status
.
currentTipAudioId
);
}
const
word
=
this
.
_status
.
currentSelectedCard
[
'
word
'
];
if
(
!
btnStart
[
'
canClick
'
])
{
return
;
}
this
.
playLocalAudio
(
'
btn
'
);
btnStart
[
'
canClick
'
]
=
false
;
asyncPlayDragonBoneAnimation
(
speaker
,
'
newAnimation
'
,
-
1
);
cc
.
tween
(
btnStart
)
.
to
(
0.1
,
{
scale
:
1.1
})
.
to
(
0.1
,
{
scale
:
1.0
})
.
call
(()
=>
{
btnStart
.
active
=
false
;
btnStop
.
active
=
true
;
btnStart
[
'
canClick
'
]
=
true
;
})
.
start
();
if
(
window
[
'
courseware
'
])
{
window
[
'
courseware
'
].
startTest
(
word
);
this
.
_status
.
isRecording
=
true
;
}
else
{
console
.
log
(
'
word =
'
+
word
);
}
});
const
baseSpeaker
=
cc
.
find
(
'
Canvas/bg/speaker
'
);
baseSpeaker
.
active
=
true
;
const
bg
=
baseSpeaker
.
getChildByName
(
'
bg
'
);
cc
.
tween
(
bg
)
.
set
({
opacity
:
0
})
.
to
(
0.5
,
{
opacity
:
100
})
.
start
();
const
speaker
=
baseSpeaker
.
getChildByName
(
'
speaker
'
);
asyncPlayDragonBoneAnimation
(
speaker
,
'
newAnimation
'
,
-
1
);
if
(
window
[
'
courseware
'
])
{
window
[
'
courseware
'
].
startTest
(
word
);
this
.
_status
.
isRecording
=
true
;
}
else
{
console
.
log
(
'
word =
'
+
word
);
}
await
asyncDelay
(
5
);
const
dragonDisplay
=
speaker
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
dragonDisplay
.
playAnimation
(
'
newAnimation
'
,
-
1
);
dragonDisplay
.
timeScale
=
0.00000001
;
let
score
=
await
this
.
stopTest
();
this
.
_status
.
isRecording
=
false
;
if
(
score
>=
60
)
{
await
this
.
showGoodjob
();
baseSpeaker
.
active
=
false
;
this
.
_status
.
tryAgainFlg
=
false
;
}
else
{
this
.
playLocalAudio
(
'
try_again
'
);
await
this
.
showTryAgain
();
}
btnStop
[
'
canClick
'
]
=
true
;
btnStop
.
off
(
'
click
'
);
btnStop
.
on
(
'
click
'
,
()
=>
{
if
(
!
btnStop
[
'
canClick
'
])
{
return
;
}
this
.
playLocalAudio
(
'
btn
'
);
btnStop
[
'
canClick
'
]
=
false
;
cc
.
tween
(
btnStop
)
.
to
(
0.1
,
{
scale
:
1.1
})
.
to
(
0.1
,
{
scale
:
1.0
})
.
call
(
async
()
=>
{
btnStop
[
'
canClick
'
]
=
true
;
btnStop
.
active
=
false
;
const
dragonDisplay
=
speaker
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
dragonDisplay
.
playAnimation
(
'
newAnimation
'
,
-
1
);
dragonDisplay
.
timeScale
=
0.00000001
;
let
score
=
await
this
.
stopTest
();
this
.
_status
.
isRecording
=
false
;
if
(
score
>=
60
)
{
await
this
.
showGoodjob
();
baseSpeaker
.
active
=
false
;
this
.
_status
.
tryAgainFlg
=
false
;
resolve
(
null
);
}
else
{
this
.
playLocalAudio
(
'
try_again
'
);
const
tryAgain
=
cc
.
find
(
'
Canvas/bg/speaker/tryAgain
'
);
await
this
.
showTryAgain
();
if
(
!
this
.
_status
.
tryAgainFlg
)
{
this
.
_status
.
tryAgainFlg
=
true
;
tryAgain
.
active
=
false
;
btnStart
.
active
=
true
;
}
else
{
const
skip
=
baseSpeaker
.
getChildByName
(
'
skip
'
);
const
doItAgain
=
baseSpeaker
.
getChildByName
(
'
doItAgain
'
);
skip
.
active
=
true
;
doItAgain
.
active
=
true
;
skip
.
once
(
'
click
'
,
()
=>
{
this
.
playLocalAudio
(
'
btn
'
);
baseSpeaker
.
active
=
false
;
tryAgain
.
active
=
false
;
skip
.
active
=
false
;
doItAgain
.
active
=
false
;
this
.
_status
.
tryAgainFlg
=
false
;
console
.
log
(
'
喵喵喵
'
);
resolve
(
null
);
});
doItAgain
.
once
(
'
click
'
,
()
=>
{
this
.
playLocalAudio
(
'
btn
'
);
tryAgain
.
active
=
false
;
btnStart
.
active
=
true
;
skip
.
active
=
false
;
doItAgain
.
active
=
false
;
});
}
btnStop
.
active
=
false
;
}
})
.
start
();
});
});
}
stopTest
()
{
...
...
@@ -561,7 +475,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
_status
=
{
canClick
:
true
,
currentSelectedCard
:
null
,
currentTipAudioId
:
null
,
tryAgainFlg
:
false
,
starLength
:
0
,
getStarNumber
:
0
,
...
...
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