Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSAPP2501
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
SSAPP2501
Commits
b659e3a4
Commit
b659e3a4
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏基础调整
parent
79617c0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
231 deletions
+151
-231
SSAPP2501.fire
assets/SSAPP2501/scene/SSAPP2501.fire
+12
-13
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+107
-218
pg.ts
assets/SSAPP2501/scene/tool/pg.ts
+32
-0
No files found.
assets/SSAPP2501/scene/SSAPP2501.fire
View file @
b659e3a4
...
@@ -7199,7 +7199,7 @@
...
@@ -7199,7 +7199,7 @@
"__id__": 156
"__id__": 156
}
}
],
],
"_active":
fals
e,
"_active":
tru
e,
"_components": [
"_components": [
{
{
"__id__": 158
"__id__": 158
...
@@ -7379,13 +7379,13 @@
...
@@ -7379,13 +7379,13 @@
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
C
omeon",
"_name": "
ani_c
omeon",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 146
"__id__": 146
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 151
"__id__": 151
...
@@ -7481,13 +7481,13 @@
...
@@ -7481,13 +7481,13 @@
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
E
xcellent",
"_name": "
ani_e
xcellent",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 146
"__id__": 146
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 153
"__id__": 153
...
@@ -7583,13 +7583,13 @@
...
@@ -7583,13 +7583,13 @@
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
N
ice",
"_name": "
ani_n
ice",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 146
"__id__": 146
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 155
"__id__": 155
...
@@ -7685,13 +7685,13 @@
...
@@ -7685,13 +7685,13 @@
},
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "
T
ryagain",
"_name": "
ani_t
ryagain",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__": 146
"__id__": 146
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 157
"__id__": 157
...
@@ -7721,7 +7721,7 @@
...
@@ -7721,7 +7721,7 @@
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0,
0,
-2
54
,
-2
25.221
,
0,
0,
0,
0,
0,
0,
...
@@ -7759,7 +7759,7 @@
...
@@ -7759,7 +7759,7 @@
}
}
],
],
"_armatureName": "armatureName",
"_armatureName": "armatureName",
"_animationName": "",
"_animationName": "
结算
",
"_preCacheMode": 0,
"_preCacheMode": 0,
"_cacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"playTimes": -1,
...
@@ -7778,7 +7778,7 @@
...
@@ -7778,7 +7778,7 @@
"__uuid__": "94fe694d-23eb-4878-911f-699e779e09f8"
"__uuid__": "94fe694d-23eb-4878-911f-699e779e09f8"
},
},
"_N$_defaultArmatureIndex": 0,
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex":
0
,
"_N$_animationIndex":
1
,
"_N$_defaultCacheMode": 0,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$debugBones": false,
...
@@ -9689,7 +9689,6 @@
...
@@ -9689,7 +9689,6 @@
"btn_audio_on": {
"btn_audio_on": {
"__id__": 94
"__id__": 94
},
},
"bg_countdown": null,
"layout_card": {
"layout_card": {
"__id__": 97
"__id__": 97
},
},
...
...
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
b659e3a4
...
@@ -47,9 +47,10 @@ let courseware = win.courseware;
...
@@ -47,9 +47,10 @@ let courseware = win.courseware;
* 提示状态枚举
* 提示状态枚举
*/
*/
enum
TIPS_STATE
{
enum
TIPS_STATE
{
GOOD
=
1
,
// 好的提示
TRYAGAIN
=
1
,
// 再试一次提示 (0星,10分以下)
TRY
,
// 再试一次提示
COMEON
,
// 加油提示 (1星,60分以下)
COM
,
// 完成提示
NICE
,
// 不错提示 (2星,80分以下)
EXCELLENT
,
// 优秀提示 (3星,80分及以上)
}
}
/**
/**
* 场景组件类
* 场景组件类
...
@@ -127,9 +128,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -127,9 +128,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
/** 音频开启按钮 */
/** 音频开启按钮 */
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
btn_audio_on
:
cc
.
Node
=
null
;
btn_audio_on
:
cc
.
Node
=
null
;
/** 倒计时背景节点 */
@
property
(
cc
.
Node
)
bg_countdown
:
cc
.
Node
=
null
;
/** 卡片布局节点 */
/** 卡片布局节点 */
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
layout_card
:
cc
.
Node
=
null
;
layout_card
:
cc
.
Node
=
null
;
...
@@ -224,7 +222,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -224,7 +222,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
layout_speak
.
active
=
false
;
this
.
layout_speak
.
active
=
false
;
this
.
layout_tip
.
active
=
false
;
// 显示问题
// 显示问题
this
.
showPage
();
this
.
showPage
();
...
@@ -405,24 +403,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -405,24 +403,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
* @param e 事件对象或包含target属性的模拟事件对象
* @param e 事件对象或包含target属性的模拟事件对象
*/
*/
private
currentFireNode
;
private
currentFireNode
;
onTouchFireNode
(
e
)
{
async
onTouchFireNode
(
e
)
{
const
fireNode
=
e
.
target
;
const
fireNode
=
e
.
target
;
// 保存触摸数据
// 保存触摸数据
this
.
touchData
=
fireNode
.
data
;
this
.
touchData
=
fireNode
.
data
;
this
.
touchData
.
parent
=
fireNode
;
this
.
touchData
.
parent
=
fireNode
;
this
.
currentFireNode
=
fireNode
;
this
.
currentFireNode
=
fireNode
;
// 1. 播放node_firetruck_flush动画(喷水)
// 1. 播放node_firetruck_flush动画(喷水)
this
.
node_firetruck_flush
.
active
=
true
;
this
.
node_firetruck_flush
.
active
=
true
;
pg
.
view
.
addDBAnimationCallback
(
this
.
node_firetruck_flush
,
()
=>
{
// 切换到持续喷水动画
pg
.
view
.
addDBAnimationCallback
(
this
.
node_firetruck_flush
,
null
)
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
持续喷水
'
,
1
);
this
.
showCard
();
})
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
喷水
'
,
1
);
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
喷水
'
,
1
);
await
pg
.
time
.
delay
(
2
);
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
持续喷水
'
,
1
);
await
pg
.
time
.
delay
(
1
);
this
.
showCard
(
false
,
'
init
'
);
}
}
onFireSuccess
()
{
onFireSuccess
()
{
...
@@ -452,11 +446,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -452,11 +446,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
log
(
`找不到节点: water_
${
fireIndex
}
`
);
this
.
log
(
`找不到节点: water_
${
fireIndex
}
`
);
}
}
pg
.
view
.
addDBAnimationCallback
(
this
.
node_firetruck_flush
,
()
=>
{
pg
.
view
.
addDBAnimationCallback
(
this
.
node_firetruck_flush
,
null
)
this
.
node_firetruck_flush
.
active
=
false
;
})
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
收水
'
,
1
);
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
收水
'
,
1
);
setTimeout
(()
=>
{
this
.
node_firetruck_flush
.
active
=
false
;
},
2000
);
this
.
touching
=
false
;
this
.
touching
=
false
;
// 检查当前页面是否所有火苗都已处理完毕
// 检查当前页面是否所有火苗都已处理完毕
...
@@ -487,7 +480,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -487,7 +480,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
showPage
();
this
.
showPage
();
}
}
showCard
(
hide
:
boolean
=
false
)
{
/**
* 显示或隐藏录音卡片
* 根据录音状态动态显示不同的按钮:
* - 未录制:显示 btn_start
* - 录制中:显示 btn_stop
* - 录制完成:显示 btn_record_replay 和 btn_start_reset
* @param hide 是否隐藏卡片,默认为false(显示)
* @param recordState 录音状态,可选值:'init'(初始状态), 'recording'(录制中), 'recorded'(录制完成)
*/
showCard
(
hide
:
boolean
=
false
,
recordState
:
string
=
'
init
'
)
{
if
(
!
hide
)
{
if
(
!
hide
)
{
// 显示卡片
// 显示卡片
const
currentData
=
this
.
currentFireNode
.
data
;
const
currentData
=
this
.
currentFireNode
.
data
;
...
@@ -509,9 +511,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -509,9 +511,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
touchOn
(
btn_stop
,
this
.
onTouchRecordEnd
,
this
);
pg
.
view
.
touchOn
(
btn_stop
,
this
.
onTouchRecordEnd
,
this
);
pg
.
view
.
touchOn
(
btn_record_replay
,
this
.
onTouchPlayRecord
,
this
);
pg
.
view
.
touchOn
(
btn_record_replay
,
this
.
onTouchPlayRecord
,
this
);
// 显示开始按钮,隐藏停止按钮
// 根据录音状态显示不同的按钮
btn_start
.
active
=
true
;
switch
(
recordState
)
{
btn_stop
.
active
=
false
;
case
'
init
'
:
// 初始状态,未录制
btn_start
.
active
=
true
;
btn_stop
.
active
=
false
;
btn_start_reset
.
active
=
false
;
btn_record_replay
.
active
=
false
;
break
;
case
'
recording
'
:
// 录制中
btn_start
.
active
=
false
;
btn_stop
.
active
=
true
;
btn_start_reset
.
active
=
false
;
btn_record_replay
.
active
=
false
;
break
;
case
'
recorded
'
:
// 录制完成
btn_start
.
active
=
false
;
btn_stop
.
active
=
false
;
btn_start_reset
.
active
=
true
;
btn_record_replay
.
active
=
true
;
break
;
default
:
// 默认显示初始状态
btn_start
.
active
=
true
;
btn_stop
.
active
=
false
;
btn_start_reset
.
active
=
false
;
btn_record_replay
.
active
=
false
;
}
}
else
{
}
else
{
// 隐藏录音界面
// 隐藏录音界面
this
.
layout_speak
.
active
=
false
;
this
.
layout_speak
.
active
=
false
;
...
@@ -527,47 +552,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -527,47 +552,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
update
(
dt
)
{
update
(
dt
)
{
// 只在游戏运行状态下更新
// 只在游戏运行状态下更新
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
// 倒计时不显示时不更新
if
(
!
this
.
bg_countdown
||
!
this
.
bg_countdown
.
active
)
return
;
// 获取时间显示节点
let
time
=
cc
.
find
(
"
time
"
,
this
.
bg_countdown
);
let
time2
=
cc
.
find
(
"
time2
"
,
this
.
bg_countdown
);
if
(
!
time
||
!
time2
)
return
;
// 倒计时结束处理
if
(
this
.
countDown
<=
0
)
{
this
.
onTouchRecordEnd
();
this
.
bg_countdown
.
active
=
false
;
cc
.
Tween
.
stopAllByTarget
(
time2
)
return
;
}
// 更新倒计时时间
this
.
countDown
=
this
.
countDown
-
dt
;
// 倒计时小于6秒时的特殊显示
if
(
this
.
countDown
<
6
)
{
let
count
=
Math
.
floor
(
this
.
countDown
);
time
.
active
=
false
;
time2
.
active
=
true
;
time2
.
getComponent
(
cc
.
Label
).
string
=
""
+
parseInt
(
""
+
this
.
countDown
);
// 当秒数变化时播放缩放动画
if
(
count
!=
this
.
timeCount
)
{
this
.
timeCount
=
count
;
cc
.
tween
(
time2
)
.
to
(
0.3
,
{
scale
:
1.1
})
.
to
(
0.3
,
{
scale
:
1
})
.
to
(
0.3
,
{
scale
:
0.9
})
.
start
()
}
}
else
{
time2
.
active
=
false
;
time
.
active
=
true
;
time
.
getComponent
(
cc
.
Label
).
string
=
""
+
parseInt
(
""
+
this
.
countDown
);
}
}
}
...
@@ -580,19 +564,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -580,19 +564,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 停止背景音乐
// 停止背景音乐
this
.
stopBgAudio
();
this
.
stopBgAudio
();
// 获取UI元素
// 获取UI元素
let
ske
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
speak_ske
'
);
// 使用更新后的showCard方法,传入'recording'状态
let
btn_start
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
btn_start
'
);
this
.
showCard
(
false
,
'
recording
'
);
let
btn_stop
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
btn_stop
'
);
// 更新按钮状态
btn_start
.
active
=
false
;
btn_stop
.
active
=
true
;
// 设置动画速度
ske
.
getComponent
(
dragonBones
.
ArmatureDisplay
).
timeScale
=
1
;
// 显示倒计时并设置时间
// 显示倒计时并设置时间
this
.
bg_countdown
.
active
=
true
;
this
.
countDown
=
this
.
startCount
;
this
.
countDown
=
this
.
startCount
;
this
.
countDown
=
this
.
touchData
.
time
||
this
.
startCount
;
//使用问题指定的时间或默认时间
this
.
countDown
=
this
.
touchData
.
time
||
this
.
startCount
;
//使用问题指定的时间或默认时间
...
@@ -601,41 +575,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -601,41 +575,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
/**
/**
* 结束录音按钮点击处理
* 结束录音按钮点击处理
* 停止倒计时,
隐藏
按钮,结束录音
* 停止倒计时,
显示播放和重新录制
按钮,结束录音
*/
*/
private
onTouchRecordEnd
()
{
private
onTouchRecordEnd
()
{
// 获取UI元素
// 使用更新后的showCard方法,传入'recorded'状态
let
ske
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
speak_ske
'
);
this
.
showCard
(
false
,
'
recorded
'
);
let
btn_start
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
btn_start
'
);
let
btn_stop
=
pg
.
view
.
find
(
this
.
layout_speak
,
'
btn_stop
'
);
// 播放动画并设置极快的速度(实际上是为了立即结束动画)
pg
.
view
.
playDBAnimation
(
ske
,
'
newAnimation
'
,
1
);
ske
.
getComponent
(
dragonBones
.
ArmatureDisplay
).
timeScale
=
10000
;
// 隐藏所有按钮
btn_stop
.
active
=
false
;
btn_start
.
active
=
false
;
// 隐藏倒计时并设置一个很大的值防止倒计时继续
// 隐藏倒计时并设置一个很大的值防止倒计时继续
this
.
bg_countdown
.
active
=
false
;
this
.
countDown
=
999999
;
this
.
countDown
=
999999
;
// 停止喷水动画
if
(
this
.
node_firetruck_flush
&&
this
.
node_firetruck_flush
.
active
)
{
// 停止持续喷水动画,切换回待机状态
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_flush
,
'
喷水
'
,
1
);
let
flushDisplay
=
this
.
node_firetruck_flush
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
if
(
flushDisplay
)
{
flushDisplay
.
timeScale
=
10
;
// 快速播放完成动画
flushDisplay
.
addEventListener
(
dragonBones
.
EventObject
.
COMPLETE
,
()
=>
{
this
.
node_firetruck_flush
.
active
=
false
;
// 恢复消防车待机动画
pg
.
view
.
playDBAnimation
(
this
.
node_firetruck_anim
,
'
待机
'
,
-
1
);
},
this
);
}
}
let
testData
=
{
let
testData
=
{
"
audioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/a8ea7bb153a46941e6f28b7d0dda49f4.mp3
"
,
"
audioUrl
"
:
"
https://staging-teach.cdn.ireadabc.com/a8ea7bb153a46941e6f28b7d0dda49f4.mp3
"
,
"
eof
"
:
1
,
"
eof
"
:
1
,
...
@@ -742,11 +690,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -742,11 +690,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
isSuccess
=
this
.
checkWords
(
data
);
let
isSuccess
=
this
.
checkWords
(
data
);
this
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
));
this
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
));
//
评分达标且单词正确
//
根据评分和单词正确性显示不同的提示
if
(
score
>=
70
&&
isSuccess
)
{
if
(
isSuccess
)
{
this
.
recordTouching
=
false
;
this
.
recordTouching
=
false
;
// 显示成功提示
this
.
updateTips
(
TIPS_STATE
.
GOOD
);
// 根据分数区间显示不同的提示
if
(
score
>=
80
)
{
// 80分及以上,显示优秀提示(3星)
this
.
updateTips
(
TIPS_STATE
.
EXCELLENT
);
}
else
if
(
score
>=
60
)
{
// 60-80分,显示不错提示(2星)
this
.
updateTips
(
TIPS_STATE
.
NICE
);
}
else
if
(
score
>=
10
)
{
// 10-60分,显示加油提示(1星)
this
.
updateTips
(
TIPS_STATE
.
COMEON
);
}
else
{
// 10分以下,显示再试一次提示(0星)
this
.
updateTips
(
TIPS_STATE
.
TRYAGAIN
);
}
// 增加正确计数
// 增加正确计数
Game
.
getIns
().
player
.
addRight
();
Game
.
getIns
().
player
.
addRight
();
this
.
tryAgain
=
false
;
this
.
tryAgain
=
false
;
...
@@ -760,13 +722,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -760,13 +722,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
await
pg
.
time
.
delay
(
3
);
await
pg
.
time
.
delay
(
3
);
this
.
showCard
(
true
);
this
.
showCard
(
true
);
this
.
updateTips
(
null
);
this
.
updateTips
(
null
);
this
.
nextEgg
();
if
(
score
>=
10
)
{
this
.
onFireSuccess
();
}
else
{
this
.
onFireFail
();
}
return
;
return
;
}
else
{
}
else
{
//
评分未达标或
单词不正确
// 单词不正确
if
(
this
.
tryData
.
some
(
td
=>
td
.
id
==
this
.
touchData
.
id
))
{
if
(
this
.
tryData
.
some
(
td
=>
td
.
id
==
this
.
touchData
.
id
))
{
// 已经尝试过的题目,显示
完成
提示
// 已经尝试过的题目,显示
加油
提示
this
.
updateTips
(
TIPS_STATE
.
COM
);
this
.
updateTips
(
TIPS_STATE
.
COM
EON
);
if
(
this
.
tryAgain
)
{
if
(
this
.
tryAgain
)
{
// 第二次尝试后,无论结果如何都进入下一题
// 第二次尝试后,无论结果如何都进入下一题
...
@@ -781,12 +747,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -781,12 +747,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
showCard
(
true
);
this
.
showCard
(
true
);
this
.
updateTips
(
null
);
this
.
updateTips
(
null
);
this
.
recordTouching
=
false
;
this
.
recordTouching
=
false
;
this
.
nextEgg
();
this
.
onFireFail
();
return
;
return
;
}
}
}
else
{
}
else
{
// 首次尝试失败,显示再试一次提示
// 首次尝试失败,显示再试一次提示
this
.
updateTips
(
TIPS_STATE
.
TRY
);
this
.
updateTips
(
TIPS_STATE
.
TRY
AGAIN
);
this
.
tryData
.
push
(
this
.
touchData
);
this
.
tryData
.
push
(
this
.
touchData
);
this
.
tryAgain
=
true
;
this
.
tryAgain
=
true
;
...
@@ -803,8 +769,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -803,8 +769,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据是否需要再次尝试决定显示卡片或进入下一题
// 根据是否需要再次尝试决定显示卡片或进入下一题
if
(
this
.
tryAgain
)
{
if
(
this
.
tryAgain
)
{
// 需要再次尝试,显示卡片和录音界面
// 需要再次尝试,显示卡片和录音界面
,重置为初始状态
this
.
showCard
()
this
.
showCard
(
false
,
'
init
'
)
}
else
{
}
else
{
// 不需要再次尝试,隐藏卡片和录音界面
// 不需要再次尝试,隐藏卡片和录音界面
this
.
showCard
(
true
)
this
.
showCard
(
true
)
...
@@ -828,113 +794,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -828,113 +794,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
layout_tip
.
active
=
true
;
this
.
layout_tip
.
active
=
true
;
// 获取所有提示图标
// 获取所有提示图标
let
img_co
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
img_co
'
);
// 完成提示
let
ani_tryagain
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
ani_tryagain
'
);
// 完成提示
let
img_gj
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
img_gj
'
);
// 很棒提示
let
ani_comeon
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
ani_comeon
'
);
// 完成提示
let
img_ta
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
img_ta
'
);
// 再试一次提示
let
ani_nice
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
ani_nice
'
);
// 完成提示
let
ani_excellent
=
pg
.
view
.
find
(
this
.
layout_tip
,
'
ani_excellent
'
);
// 完成提示
// 先隐藏所有图标
img_co
.
active
=
false
;
ani_tryagain
.
active
=
false
;
img_gj
.
active
=
false
;
ani_comeon
.
active
=
false
;
img_ta
.
active
=
false
;
ani_nice
.
active
=
false
;
ani_excellent
.
active
=
false
;
// 根据状态选择要显示的图标和光效
let
img
=
null
;
let
img_light
=
null
;
switch
(
state
)
{
switch
(
state
)
{
case
TIPS_STATE
.
COM
:
// 完成
case
TIPS_STATE
.
TRYAGAIN
:
// 再试一次(0星,10分以下)
img
=
img_co
;
ani_tryagain
.
active
=
true
;
img_light
=
cc
.
find
(
"
bg_light
"
,
img_co
);
pg
.
view
.
playDBAnimation
(
ani_tryagain
,
'
结算
'
,
1
);
this
.
playLocalAudio
(
"
co
"
);
// 播放完成音效
break
;
break
;
case
TIPS_STATE
.
GOOD
:
// 很棒
case
TIPS_STATE
.
COMEON
:
// 加油(1星,60分以下)
img
=
img_gj
;
ani_comeon
.
active
=
true
;
this
.
playLocalAudio
(
"
gj
"
);
// 播放很棒音效
pg
.
view
.
playDBAnimation
(
ani_comeon
,
'
结算
'
,
1
);
img_light
=
cc
.
find
(
"
bg_light
"
,
img_gj
);
break
;
break
;
case
TIPS_STATE
.
TRY
:
// 再试一次
case
TIPS_STATE
.
NICE
:
// 不错(2星,80分以下)
img
=
img_ta
;
ani_nice
.
active
=
true
;
this
.
playLocalAudio
(
"
ta
"
);
// 播放再试一次音效
pg
.
view
.
playDBAnimation
(
ani_nice
,
'
结算
'
,
1
);
img_light
=
cc
.
find
(
"
bg_light
"
,
img_ta
);
break
;
case
TIPS_STATE
.
EXCELLENT
:
// 优秀(3星,80分及以上)
ani_excellent
.
active
=
true
;
pg
.
view
.
playDBAnimation
(
ani_excellent
,
'
结算
'
,
1
);
break
;
break
;
}
}
// 设置初始缩放为0并显示
img
.
scale
=
0
;
img
.
active
=
true
;
// 停止之前的动画并激活光效
cc
.
Tween
.
stopAllByTarget
(
img_light
)
img_light
.
active
=
true
;
// 创建光效旋转动画
cc
.
tween
(
img_light
).
repeatForever
(
cc
.
tween
().
by
(
5
,
{
angle
:
360
})).
start
();
// 创建图标缩放动画,延迟后自动隐藏
cc
.
tween
(
img
).
to
(
0.5
,
{
scale
:
1
}).
delay
(
2
).
call
(()
=>
{
cc
.
Tween
.
stopAllByTarget
(
img_light
)
this
.
layout_tip
.
active
=
false
;
}).
start
();
}
/**
* 处理下一个蛋壳的显示
* 如果还有问题,重置当前蛋壳并显示新问题
* 如果没有问题了,检查游戏是否结束
*/
private
nextEgg
()
{
// 获取下一个问题数据
let
eggInfo
=
Game
.
getIns
().
getCardInfo
();
if
(
eggInfo
)
{
// 还有问题,重置当前蛋壳
let
egg
=
this
.
touchData
.
parent
;
let
di
=
cc
.
find
(
"
di
"
,
egg
);
let
intact
=
cc
.
find
(
"
intact
"
,
egg
);
let
broken
=
cc
.
find
(
"
broken
"
,
egg
);
// 恢复蛋壳完整状态
di
.
active
=
false
;
broken
.
active
=
false
;
intact
.
active
=
true
;
// 设置新的问题数据
egg
.
data
=
eggInfo
;
// 将重置的火苗节点添加回活跃列表
if
(
!
this
.
activeFireNodes
.
includes
(
egg
))
{
this
.
activeFireNodes
.
push
(
egg
);
}
}
else
{
// 没有问题了,隐藏当前蛋壳
this
.
touchData
.
parent
.
active
=
false
;
// 检查是否所有蛋壳都已处理完毕
// if (this.checkIsOver()) {
// this.gameOver();
// }
}
// 恢复背景音乐
this
.
playBgAudio
();
}
}
/**
* 为蛋壳添加箭头上下移动动画
* @param target 目标蛋壳节点
*/
private
eggArrowAction
(
target
)
{
// 获取箭头节点
let
icon_arrow
=
cc
.
find
(
"
icon_arrow
"
,
target
);
if
(
!
icon_arrow
)
return
;
// 显示箭头并创建上下移动的循环动画
icon_arrow
.
active
=
true
;
cc
.
tween
(
icon_arrow
).
repeatForever
(
cc
.
tween
().
to
(
0.5
,
{
y
:
180
}).
to
(
0.5
,
{
y
:
220
})
).
start
();
}
/**
/**
* 检查录音单词的正确性
* 检查录音单词的正确性
...
...
assets/SSAPP2501/scene/tool/pg.ts
View file @
b659e3a4
...
@@ -619,6 +619,38 @@ let pg = {
...
@@ -619,6 +619,38 @@ let pg = {
return
skl
;
return
skl
;
},
},
/**
* 为DragonBones动画添加一次性的动画完成回调事件,回调触发一次后自动移除
* @param {cc.Node|cc.Component} item - 包含DragonBones组件的节点或组件
* @returns {dragonBones.ArmatureDisplay} DragonBones骨骼组件
*/
addDBAnimationCallbackOnce
(
item
,
callback
)
{
if
(
!
item
||
!
cc
.
isValid
(
item
))
return
pg
.
logger
.
w
(
"
添加一次性动画回调失败,传入了错误的item
"
);
if
(
!
callback
)
return
pg
.
logger
.
w
(
"
添加一次性动画回调失败,未传入回调函数
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
if
(
!
cc
.
isValid
(
node
))
return
pg
.
logger
.
w
(
"
节点已销毁
"
);
let
skl
:
dragonBones
.
ArmatureDisplay
=
node
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
if
(
!
skl
)
return
pg
.
logger
.
w
(
"
节点上没有DragonBones组件
"
);
// 创建一个包装回调,在执行原始回调后自动移除监听器
const
onceCallback
=
(
event
)
=>
{
// 先移除监听器,防止回调中可能的异常导致监听器未被移除
skl
.
removeEventListener
(
dragonBones
.
EventObject
.
COMPLETE
);
// 执行原始回调
callback
(
event
);
};
// 移除之前可能存在的监听器,避免重复添加
skl
.
removeEventListener
(
dragonBones
.
EventObject
.
COMPLETE
,
onceCallback
);
// 添加一次性动画完成事件监听
skl
.
addEventListener
(
dragonBones
.
EventObject
.
COMPLETE
,
onceCallback
);
return
skl
;
},
/**
/**
* 设置DragonBones动画的播放速度
* 设置DragonBones动画的播放速度
* @param {cc.Node|cc.Component} item - 包含DragonBones组件的节点或组件
* @param {cc.Node|cc.Component} item - 包含DragonBones组件的节点或组件
...
...
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