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
6cd9e2cc
Commit
6cd9e2cc
authored
Aug 08, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(play): 重构鱼点击处理逻辑,拆分动画和存储功能
parent
40327941
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
54 deletions
+60
-54
play.component.ts
src/app/play/play.component.ts
+60
-54
No files found.
src/app/play/play.component.ts
View file @
6cd9e2cc
...
...
@@ -1052,7 +1052,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console
.
log
(
'
fish click
'
,
fish
);
// 点击气泡时执行brokePaopao方法
this
.
touchFish
=
fish
;
this
.
brokePaopao
(
fish
);
this
.
onTouchFish
(
fish
);
setTimeout
(()
=>
{
this
.
touchFish
=
null
;
},
100
);
...
...
@@ -1067,7 +1067,7 @@ export class PlayComponent implements OnInit, OnDestroy {
* 存储用户点击的鱼的数据,检查是否有两个正确数据
* @param fish 被点击的鱼对象
*/
brokePaopao
(
fish
)
{
onTouchFish
(
fish
)
{
// 获取当前游戏阶段
const
currentStage
=
this
.
gameStages
[
this
.
currentStageIndex
];
...
...
@@ -1094,37 +1094,10 @@ export class PlayComponent implements OnInit, OnDestroy {
// 创建飞向水桶的小鱼动画
this
.
createFlyingFish
(
fish
);
this
.
brokePaopaoAni
(
fish
);
this
.
saveFishRight
(
fish
);
// 存储用户点击的鱼的数据
if
(
fish
.
questionData
)
{
this
.
clickedFishData
.
push
(
fish
.
questionData
);
console
.
log
(
'
Clicked fish count:
'
,
this
.
clickedFishData
.
length
);
// 计算正确点击的次数
const
correctClicks
=
this
.
clickedFishData
.
filter
(
data
=>
data
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
data
.
image
===
currentStage
.
correctQuestion
.
image
).
length
;
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
{
// 错误小鱼的处理逻辑
// 播放错误音效
...
...
@@ -1136,9 +1109,10 @@ export class PlayComponent implements OnInit, OnDestroy {
fish
.
speed
=
originalSpeed
;
},
1000
);
}
return
fish
;
}
brokePaopaoAni
(
fish
)
{
// 对于正确的鱼,显示泡泡破裂动画
if
(
isCorrect
)
{
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let
currentFrame
=
1
;
const
maxFrame
=
9
;
...
...
@@ -1162,8 +1136,40 @@ export class PlayComponent implements OnInit, OnDestroy {
fish
.
speed
=
0
;
}
return
fish
;
saveFishRight
(
fish
)
{
const
currentStage
=
this
.
gameStages
[
this
.
currentStageIndex
];
if
(
fish
.
questionData
)
{
this
.
clickedFishData
.
push
(
fish
.
questionData
);
console
.
log
(
'
Clicked fish count:
'
,
this
.
clickedFishData
.
length
);
// 计算正确点击的次数
const
correctClicks
=
this
.
clickedFishData
.
filter
(
data
=>
data
.
audio
===
currentStage
.
correctQuestion
.
audio
&&
data
.
image
===
currentStage
.
correctQuestion
.
image
).
length
;
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
);
}
}
}
aniOpacity
(
fish
)
{
// 使用alphaItem创建平滑的透明度变化动画
...
...
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