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
f521198c
Commit
f521198c
authored
Aug 09, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(play): 添加321倒计时动画功能
parent
04ee86bd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
1 deletion
+134
-1
play.component.ts
src/app/play/play.component.ts
+134
-1
No files found.
src/app/play/play.component.ts
View file @
f521198c
...
@@ -211,6 +211,136 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -211,6 +211,136 @@ export class PlayComponent implements OnInit, OnDestroy {
});
});
}
}
/**
* 隐藏所有321倒计时相关元素
*/
hide321Elements
()
{
// 隐藏倒计时元素
const
countdownElements
=
[
'
dao_ji_shi_3
'
,
'
dao_ji_shi_2
'
,
'
dao_ji_shi_1
'
];
countdownElements
.
forEach
(
elementName
=>
{
const
element
=
this
.
g_cartoon
.
cartoonElementsBuffer
[
elementName
];
if
(
element
&&
element
.
ref
)
{
element
.
ref
.
visible
=
false
;
}
});
}
/**
* 初始化321倒计时视图
* 创建并初始化倒计时数字元素
*/
init321View
()
{
// 创建倒计时数字元素
const
countdownElements
=
[
'
dao_ji_shi_3
'
,
'
dao_ji_shi_2
'
,
'
dao_ji_shi_1
'
];
countdownElements
.
forEach
(
elementName
=>
{
// 检查元素是否已存在
if
(
!
this
.
g_cartoon
.
cartoonElementsBuffer
[
elementName
])
{
// 创建元素
const
element
=
this
.
g_cartoon
.
createCartoonElement
(
elementName
,
'
MySprite
'
);
// 初始化元素
element
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
elementName
));
// 设置元素缩放
element
.
ref
.
scaleX
=
this
.
g_mapScale
;
element
.
ref
.
scaleY
=
this
.
g_mapScale
;
// 设置元素位置(画面中心)
element
.
ref
.
x
=
this
.
g_canvasWidth
/
2
;
element
.
ref
.
y
=
this
.
g_canvasHeight
/
2
;
// 默认隐藏
element
.
ref
.
visible
=
false
;
// 添加到渲染队列
this
.
render
(
element
.
ref
,
zIndexMap
.
card
+
3
);
}
});
}
/**
* 显示321倒计时动画
* 依次显示3、2、1的倒计时动画效果
*/
show321
()
{
// 动画配置参数
const
config
=
{
// 动画时间配置
time
:
{
displayDuration
:
0.7
,
// 数字显示停留时间(秒)
animDuration
:
0.3
,
// 动画持续时间(秒)
interval
:
0
,
// 数字切换间隔时间(秒)
afterComplete
:
0.5
// 倒计时完成后的延迟时间(秒)
},
// 动画效果配置
effect
:
{
scaleRatio
:
3
,
// 放大比例
finalAlpha
:
0.5
// 最终透明度
}
};
// 初始化321倒计时视图
this
.
init321View
();
// 隐藏所有倒计时元素(确保初始状态是隐藏的)
this
.
hide321Elements
();
// 依次显示3、2、1的倒计时动画
// 先显示3
this
.
showCountdownNumber
(
'
dao_ji_shi_3
'
,
config
,
()
=>
{
// 显示完3后显示2
this
.
showCountdownNumber
(
'
dao_ji_shi_2
'
,
config
,
()
=>
{
// 显示完2后显示1
this
.
showCountdownNumber
(
'
dao_ji_shi_1
'
,
config
,
()
=>
{
// 倒计时结束后的操作,等待一段时间后显示VS动画
setTimeout
(()
=>
{
this
.
showVsAni
(
'
left
'
);
},
config
.
time
.
afterComplete
*
1000
);
});
});
});
}
/**
* 显示单个倒计时数字的动画
* @param elementName 元素名称
* @param config 动画配置
* @param callback 动画完成后的回调函数
*/
showCountdownNumber
(
elementName
,
config
,
callback
)
{
// 获取倒计时元素
const
element
=
this
.
g_cartoon
.
cartoonElementsBuffer
[
elementName
];
if
(
element
&&
element
.
ref
)
{
// 重置元素状态
element
.
ref
.
visible
=
true
;
element
.
ref
.
alpha
=
1
;
element
.
ref
.
scaleX
=
this
.
g_mapScale
;
element
.
ref
.
scaleY
=
this
.
g_mapScale
;
// 先显示数字一段时间,然后再执行放大消失动画
setTimeout
(()
=>
{
// 创建放大和透明度变化的动画
tweenChange
(
element
.
ref
,
{
scaleX
:
this
.
g_mapScale
*
config
.
effect
.
scaleRatio
,
scaleY
:
this
.
g_mapScale
*
config
.
effect
.
scaleRatio
,
alpha
:
config
.
effect
.
finalAlpha
},
config
.
time
.
animDuration
,
()
=>
{
// 动画完成后隐藏元素
element
.
ref
.
visible
=
false
;
// 延迟执行回调函数
setTimeout
(()
=>
{
if
(
callback
)
{
callback
();
}
},
config
.
time
.
interval
*
1000
);
// 延迟间隔时间后执行下一个数字的动画
});
},
config
.
time
.
displayDuration
*
1000
);
// 显示停留时间
}
else
{
// 如果元素不存在,直接执行回调
if
(
callback
)
{
callback
();
}
}
}
/**
/**
* 映射预加载图片[网络]资源
* 映射预加载图片[网络]资源
* 从内容对象中提取所有图片URL,用于预加载
* 从内容对象中提取所有图片URL,用于预加载
...
@@ -295,8 +425,11 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -295,8 +425,11 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.initListPage();
// this.initListPage();
// 显示321倒计时动画
this
.
show321
();
// 显示VS动画
// 显示VS动画
this
.
showVsAni
(
'
left
'
);
//
this.showVsAni('left');
// this.initFishGame();
// this.initFishGame();
...
...
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