|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Asset, Component, Constructor, director, Node, ParticleSystem, Prefab, SceneAsset, setPropertyEnumType, SkeletalAnimation, Sprite, SpriteFrame, tween, UIOpacity, v2, v3, Vec3 } from 'cc';
|
|
|
+import { _decorator, AnimationState, Asset, Constructor, director, Node, ParticleSystem, Prefab, SceneAsset, SkeletalAnimation, Sprite, SpriteFrame, tween, UIOpacity, v2, v3, Vec3 } from 'cc';
|
|
|
import { Utils } from './Utils';
|
|
|
import { Constants } from '../data/Constants';
|
|
|
import { bundleMgr } from '../core/manager/BundleManager';
|
|
@@ -256,14 +256,15 @@ export class ResUtil {
|
|
|
}
|
|
|
//核心逻辑:通过调整播放速度,使动画总时长等于传入的time
|
|
|
//公式推导:原始时长 = 播放速度 × 实际播放时间 → 播放速度 = 原始时长 / 目标时长
|
|
|
+ let animState:AnimationState = skeletal.getState(name);
|
|
|
if(time > 0) {
|
|
|
- clip.speed = clip.duration / time;
|
|
|
+ animState.speed = clip.duration / time;
|
|
|
}else{//恢复默认速度(避免之前的修改影响后续播放)
|
|
|
- clip.speed = 1;
|
|
|
+ animState.speed = 1;
|
|
|
}
|
|
|
skeletal.play(name);
|
|
|
if(cb){
|
|
|
- skeletal.scheduleOnce(cb,time);
|
|
|
+ skeletal.scheduleOnce(cb,time > 0 ? time : clip.duration);
|
|
|
}
|
|
|
}
|
|
|
|