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
d64bc800
Commit
d64bc800
authored
Aug 20, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 提高鱼的移动速度以增强游戏体验
parent
e3bc91dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
play.component.ts
src/app/play/play.component.ts
+3
-3
No files found.
src/app/play/play.component.ts
View file @
d64bc800
...
...
@@ -994,7 +994,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 计算鱼从右侧游到左侧所需的时间(毫秒)
// 假设鱼的速度为1像素/帧,帧率约为60fps,则速度约为60像素/秒
// 屏幕宽度加上鱼的宽度,再除以速度,得到鱼游过整个屏幕的时间
const
fishSpeed
=
1
;
// 鱼的移动速度
const
fishSpeed
=
2
;
// 鱼的移动速度
const
fishWidth
=
374
*
this
.
g_mapScale
*
(
type
===
'
small
'
?
0.7
:
1
);
// 估计的鱼宽度
const
screenWidth
=
this
.
g_canvasWidth
+
fishWidth
*
0
;
// 屏幕宽度加上鱼的宽度
const
fishCrossingTime
=
(
screenWidth
/
fishSpeed
)
*
(
1000
/
60
);
// 鱼游过屏幕所需的时间(毫秒)
...
...
@@ -1044,7 +1044,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console
.
log
(
'
Is correct:
'
,
isCorrect
);
// 保存鱼的原始速度,用于后续恢复
const
originalSpeed
=
fish
.
speed
||
0.3
;
const
originalSpeed
=
fish
.
speed
||
2
;
// 点击后立即停止鱼的运动
fish
.
speed
=
0
;
...
...
@@ -2974,7 +2974,7 @@ export class PlayComponent implements OnInit, OnDestroy {
fish
.
ref
.
y
=
(
this
.
currentFishIndex
%
2
==
0
?
400
:
300
)
*
this
.
g_mapScale
;
// Math.random() * (this.g_canvasHeight * 0.35) + this.g_canvasHeight * 0.25; // 在屏幕中间区域随机高度
// 设置鱼的游动速度
fish
.
speed
=
1
;
fish
.
speed
=
2
;
// 确保鱼已添加到渲染队列中
// createFish 方法中已经调用了 render 方法,但为了确保,这里再次检查
...
...
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