refactor(map): 重构地图动画播放逻辑,修复速度残留问题
1. 给playAnimations方法新增speed参数,支持自定义播放倍率 2. 移除硬编码的4倍速,改用可配置的常量 3. 调用处传入明确speed值,避免上一次加速状态残留 4. 补充方法注释说明参数含义和设计原因
This commit is contained in:
@@ -89,14 +89,19 @@ export default class MapLayer extends Component {
|
||||
/** 背景滚动播放速度倍率(节间过场加快推进感) */
|
||||
private static readonly SCROLL_SPEED = 4;
|
||||
|
||||
public playAnimations(name?: string): void {
|
||||
/**
|
||||
* 播放背景滚动动画。
|
||||
* @param name 动画名(缺省播 defaultClip)
|
||||
* @param speed 播放速度倍率:大厅/常态=1,节间过场=SCROLL_SPEED。
|
||||
* 每次 play 都显式覆盖 state.speed,避免上一次 4x 加速残留泄漏到大厅。
|
||||
*/
|
||||
public playAnimations(name?: string, speed: number = 1): void {
|
||||
this.animations.forEach(a => {
|
||||
a.play(name);
|
||||
// 加快背景滚动速度,强化节间"向前推进"的观感(AnimationState.speed 属性)
|
||||
const clip = a.defaultClip;
|
||||
if (clip) {
|
||||
const state = a.getState(clip.name);
|
||||
if (state) state.speed = MapLayer.SCROLL_SPEED;
|
||||
if (state) state.speed = speed;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user