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
cb214a80
Commit
cb214a80
authored
Aug 07, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(play): 添加小鱼飞向水桶的动画效果
parent
89d42798
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
play.component.ts
src/app/play/play.component.ts
+51
-0
No files found.
src/app/play/play.component.ts
View file @
cb214a80
...
...
@@ -971,6 +971,7 @@ export class PlayComponent implements OnInit, OnDestroy {
fish
[
'
child_image
'
].
ref
.
visible
=
false
;
fish
[
'
child_paopao_ani
'
].
ref
.
visible
=
true
;
this
.
createFlyingFish
(
fish
);
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let
currentFrame
=
1
;
const
maxFrame
=
9
;
...
...
@@ -991,6 +992,56 @@ export class PlayComponent implements OnInit, OnDestroy {
return
fish
;
}
/**
* 创建临时小鱼并飞向水桶
* @param fish 原始鱼对象
*/
createFlyingFish
(
fish
)
{
// 1. 获取小鱼的全局坐标
const
xiao_yu
=
fish
[
'
child_xiao_yu
'
];
const
fishGlobalX
=
fish
.
ref
.
x
+
xiao_yu
.
ref
.
x
;
const
fishGlobalY
=
fish
.
ref
.
y
+
xiao_yu
.
ref
.
y
;
// 2. 创建一个临时小鱼
const
tempFishId
=
`temp_fish_
${
Math
.
floor
(
Math
.
random
()
*
1000
)}
_
${
Date
.
now
()}
`
;
const
tempFish
=
this
.
g_cartoon
.
createCartoonElement
(
tempFishId
,
'
MySprite
'
);
// 使用与原小鱼相同的图像
tempFish
.
ref
.
init
(
xiao_yu
.
ref
.
img
);
tempFish
.
ref
.
scaleX
=
xiao_yu
.
ref
.
scaleX
;
tempFish
.
ref
.
scaleY
=
xiao_yu
.
ref
.
scaleY
;
// 设置临时小鱼的全局位置
tempFish
.
ref
.
x
=
fishGlobalX
;
tempFish
.
ref
.
y
=
fishGlobalY
;
// 3. 获取水桶的全局位置
const
tong
=
this
.
cat_center
[
'
child_tong_left
'
];
const
tongGlobalX
=
this
.
cat_center
.
ref
.
x
+
tong
.
ref
.
x
;
const
tongGlobalY
=
this
.
cat_center
.
ref
.
y
+
tong
.
ref
.
y
;
// 将临时小鱼添加到舞台
this
.
render
(
tempFish
.
ref
,
zIndexMap
.
card
+
1
);
// 4. 创建小鱼飞向水桶的动画
tweenChange
(
tempFish
.
ref
,
{
x
:
tongGlobalX
,
y
:
tongGlobalY
,
scaleX
:
tempFish
.
ref
.
scaleX
*
0.5
,
// 飞行过程中缩小
scaleY
:
tempFish
.
ref
.
scaleY
*
0.5
},
0.8
,
// 动画时间
()
=>
{
// 动画完成后移除临时小鱼
this
.
m_renderArr
=
this
.
m_renderArr
.
filter
(
item
=>
item
!==
tempFish
.
ref
);
tempFish
.
ref
.
visible
=
false
;
},
TWEEN
.
Easing
.
Quadratic
.
Out
// 使用缓动函数使动画更平滑
);
}
...
...
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