Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
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
SSIWB2504
Commits
40327941
Commit
40327941
authored
Aug 08, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小鱼错误已完成
parent
8799433b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
53 deletions
+105
-53
play.component.ts
src/app/play/play.component.ts
+105
-53
No files found.
src/app/play/play.component.ts
View file @
40327941
...
...
@@ -24,7 +24,8 @@ import {
showItem
,
ShapeRectNew
,
scaleItem
,
showBlingBling
showBlingBling
,
alphaItem
}
from
"
./Unit
"
;
import
{
localImages
,
localAudios
,
localImagesSize
}
from
"
./resources
"
;
...
...
@@ -777,7 +778,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 修改鱼的生成逻辑,使用当前阶段的随机问题列表
this
.
m_fishInterval
=
3000
;
// 设置鱼的生成间隔为3秒
this
.
m_lastFishTime
=
0
;
// 重置上次生成鱼的时间,使下一帧立即生成鱼
// 每一个stage开始的时候播放一次正确问题的音频
if
(
currentStage
.
correctQuestion
&&
currentStage
.
correctQuestion
.
audio
)
{
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
);
...
...
@@ -1067,76 +1068,127 @@ export class PlayComponent implements OnInit, OnDestroy {
* @param fish 被点击的鱼对象
*/
brokePaopao
(
fish
)
{
// 隐藏泡泡背景、小鱼和图片
fish
[
'
child_paopao_bg
'
].
ref
.
visible
=
false
;
fish
[
'
child_xiao_yu
'
].
ref
.
visible
=
false
;
fish
[
'
child_image
'
].
ref
.
visible
=
false
;
fish
[
'
child_paopao_ani
'
].
ref
.
visible
=
true
;
// 创建飞向水桶的小鱼动画
this
.
createFlyingFish
(
fish
);
// 获取当前游戏阶段
const
currentStage
=
this
.
gameStages
[
this
.
currentStageIndex
];
// 存储用户点击的鱼的数据
if
(
fish
.
questionData
)
{
this
.
clickedFishData
.
push
(
fish
.
questionData
);
// 检查是否点击了正确的鱼
const
isCorrect
=
fish
.
questionData
&&
fish
.
questionData
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
fish
.
questionData
.
image
===
currentStage
.
correctQuestion
.
image
;
// 检查是否点击了正确的鱼
const
isCorrect
=
fish
.
questionData
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
fish
.
questionData
.
image
===
currentStage
.
correctQuestion
.
image
;
console
.
log
(
'
Clicked fish data:
'
,
fish
.
questionData
);
console
.
log
(
'
Is correct:
'
,
isCorrect
);
console
.
log
(
'
Clicked fish data:
'
,
fish
.
questionData
);
console
.
log
(
'
Is correct:
'
,
isCorrect
);
console
.
log
(
'
Clicked fish count:
'
,
this
.
clickedFishData
.
length
);
// 保存鱼的原始速度,用于后续恢复
const
originalSpeed
=
fish
.
speed
||
0.3
;
// 点击后立即停止鱼的运动
fish
.
speed
=
0
;
// 计算正确点击的次数
const
correctClicks
=
this
.
clickedFishData
.
filter
(
data
=>
data
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
data
.
image
===
currentStage
.
correctQuestion
.
image
).
length
;
if
(
isCorrect
)
{
// 正确小鱼的处理逻辑
// 隐藏泡泡背景、小鱼和图片
fish
[
'
child_paopao_bg
'
].
ref
.
visible
=
false
;
fish
[
'
child_xiao_yu
'
].
ref
.
visible
=
false
;
fish
[
'
child_image
'
].
ref
.
visible
=
false
;
fish
[
'
child_paopao_ani
'
].
ref
.
visible
=
true
;
console
.
log
(
'
Correct clicks:
'
,
correctClicks
);
// 创建飞向水桶的小鱼动画
this
.
createFlyingFish
(
fish
);
//
如果有两个数据为当前Stage的正确数据,则清空画面,等待1秒后进入下一轮游戏
if
(
correctClicks
>=
2
)
{
console
.
log
(
'
Stage completed! Moving to next stage...
'
);
//
存储用户点击的鱼的数据
if
(
fish
.
questionData
)
{
this
.
clickedFishData
.
push
(
fish
.
questionData
);
// 清空画面(清除所有鱼)
this
.
clearFishes
();
console
.
log
(
'
Clicked fish count:
'
,
this
.
clickedFishData
.
length
);
// 增加当前阶段索引
this
.
currentStageIndex
++
;
// 计算正确点击的次数
const
correctClicks
=
this
.
clickedFishData
.
filter
(
data
=>
data
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
data
.
image
===
currentStage
.
correctQuestion
.
image
).
length
;
// 等待1秒后进入下一轮游戏
setTimeout
(()
=>
{
this
.
initNextStage
();
},
1000
);
console
.
log
(
'
Correct clicks:
'
,
correctClicks
);
// 如果有两个数据为当前Stage的正确数据,则清空画面,等待1秒后进入下一轮游戏
if
(
correctClicks
>=
2
)
{
console
.
log
(
'
Stage completed! Moving to next stage...
'
);
// 清空画面(清除所有鱼)
this
.
clearFishes
();
// 增加当前阶段索引
this
.
currentStageIndex
++
;
// 等待1秒后进入下一轮游戏
setTimeout
(()
=>
{
this
.
initNextStage
();
},
1000
);
}
}
}
else
{
// 错误小鱼的处理逻辑
// 播放错误音效
this
.
g_cartoon
.
playAudio
(
'
click_wrong
'
);
this
.
aniOpacity
(
fish
);
// 1秒后恢复鱼的运动
setTimeout
(()
=>
{
fish
.
speed
=
originalSpeed
;
},
1000
);
}
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let
currentFrame
=
1
;
const
maxFrame
=
9
;
const
frameInterval
=
100
;
// 每帧间隔时间,可以根据需要调整
const
playNextFrame
=
()
=>
{
if
(
currentFrame
<=
maxFrame
)
{
// 设置当前帧的图像
fish
[
'
child_paopao_ani
'
].
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
`pao_pao_xu_lie_zhen_
${
currentFrame
}
`
));
currentFrame
++
;
// 设置下一帧的定时器
setTimeout
(
playNextFrame
,
frameInterval
);
}
};
// 对于正确的鱼,显示泡泡破裂动画
if
(
isCorrect
)
{
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let
currentFrame
=
1
;
const
maxFrame
=
9
;
const
frameInterval
=
100
;
// 每帧间隔时间,可以根据需要调整
const
playNextFrame
=
()
=>
{
if
(
currentFrame
<=
maxFrame
)
{
// 设置当前帧的图像
fish
[
'
child_paopao_ani
'
].
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
`pao_pao_xu_lie_zhen_
${
currentFrame
}
`
));
currentFrame
++
;
// 设置下一帧的定时器
setTimeout
(
playNextFrame
,
frameInterval
);
}
};
// 开始播放序列帧动画
playNextFrame
();
// 开始播放序列帧动画
playNextFrame
();
// 正确的鱼不需要恢复运动,因为它们已经被处理了
// 确保鱼保持停止状态
fish
.
speed
=
0
;
}
return
fish
;
}
aniOpacity
(
fish
)
{
// 使用alphaItem创建平滑的透明度变化动画
const
childNames
=
[
'
child_image
'
,
'
child_paopao_bg
'
]
childNames
.
forEach
(
childName
=>
{
// 先变为半透明
alphaItem
(
fish
[
childName
].
ref
,
0.5
,
0.1
,
()
=>
{
// 0.5秒后恢复原始透明度,使用0.3秒的动画时间
setTimeout
(()
=>
{
alphaItem
(
fish
[
childName
].
ref
,
1
,
0.1
);
setTimeout
(()
=>
{
alphaItem
(
fish
[
childName
].
ref
,
0.5
,
0.1
,
()
=>
{
// 0.5秒后恢复原始透明度,使用0.1秒的动画时间
setTimeout
(()
=>
{
alphaItem
(
fish
[
childName
].
ref
,
1
,
0.1
);
},
100
);
});
},
100
);
},
100
);
});
})
}
/**
* 创建临时小鱼并飞向水桶
* @param fish 原始鱼对象
...
...
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