feat(guide): 添加引导手势动画播放功能

新增dianji(点击)、huadong(滑动)两款手势动画资源及元数据文件
扩展GuideComp引导组件:新增CCString导入、动画名称配置属性,实现延迟加载并播放指定动画的逻辑,包含异常日志处理
更新引导预制体:将原hand节点重命名为shouzhi,添加Animation组件并绑定两款动画剪辑,调整默认配置
This commit is contained in:
pan
2026-06-12 08:57:44 +08:00
parent 1c74138334
commit 531343c0d7
7 changed files with 1547 additions and 240 deletions

View File

@@ -1,6 +1,6 @@
import { mLogger } from "../common/Logger";
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources, Light, UITransform, Widget, CCInteger } from "cc";
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources, Light, UITransform, Widget, CCInteger, CCString } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp";
@@ -22,7 +22,9 @@ export class GuideComp extends CCComp {
/** 引导编号 ID */
@property({ type: CCInteger })
guide_id: number = 0
/** 动画名称 ID */
@property({ type: CCString })
animation_name: string = 'dianji';
onLoad() {
// 如果该引导已经完成,则隐藏并销毁本节点
@@ -32,6 +34,35 @@ export class GuideComp extends CCComp {
return;
}
// 播放手势动画
if (this.hand && this.animation_name) {
// 延迟一帧播放,防止组件还未完全激活
this.scheduleOnce(() => {
if (!this.isValid) return; // 防止节点已被销毁
// 1. 先尝试在绑定的 this.hand 本身上查找 Animation 组件
let anim = this.hand.getComponent(Animation);
// 2. 如果没找到,再尝试去它的子节点上找
if (!anim) {
anim = this.hand.getComponentInChildren(Animation);
}
if (anim) {
// 确保目标动画状态存在
const animState = anim.getState(this.animation_name);
if (animState) {
anim.play(this.animation_name);
mLogger.log(this.debugMode, 'Guide', `成功播放引导动画: ${this.animation_name}`);
} else {
mLogger.warn(this.debugMode, 'Guide', `找到了 Animation 组件,但组件内未挂载名为 '${this.animation_name}' 的动画剪辑(Clip)。请检查编辑器 Animation 组件的 Clips 列表!`);
}
} else {
mLogger.warn(this.debugMode, 'Guide', `在 hand 节点及其子节点下均未找到 Animation 组件,无法播放动画: ${this.animation_name}`);
}
});
}
// 监听手势节点点击事件
if (this.hand) {
this.hand.on(NodeEventType.TOUCH_START, this.onTouchStart, this);