import { _decorator, Component, Node, Animation, Sprite, resources, SpriteFrame, CCString, CCInteger, Vec2 } from 'cc'; import { MyAnimation } from './MyAnimation'; const { ccclass, property, requireComponent, executeInEditMode } = _decorator; @ccclass('BaseMyAnimation') @requireComponent(Sprite)//依赖组件 精灵 export default class BaseMyAnimation extends MyAnimation { @property({ type: CCInteger, displayName: 'Ani帧数', tooltip: "Ani总共有多少帧" }) AnimationFrameCount: number = 0; NowSettingCount = 0; @property({ type: CCString, displayName: '默认img路径', tooltip: "img路径" }) DefaultImgPath: string = ""; @property({ type: [CCString], displayName: 'img路径', tooltip: "img路径" }) ImgPath: string[] = Array(); @property({ type: [CCInteger], displayName: 'img编号', tooltip: "img编号" }) ImgIndex: number[] = Array(); @property({ type: [CCInteger], displayName: '每帧时间', tooltip: "每一帧的持续时间" }) FrameDelay: Array = Array(); ChangeArr(Aobj, Bobj, FillData) { if (Aobj.length < Bobj) { for (let index = 0; index < (Bobj - Aobj.length); index++) { Aobj.push(FillData); } } else if (Aobj.length > Bobj) { for (let index = 0; index < (Aobj.length - Bobj); index++) { Aobj.pop(); } } } onAnimationFrameCountChanged() { //如果更改了设置 if (this.NowSettingCount != this.AnimationFrameCount) { this.ChangeArr(this.ImgPath, this.AnimationFrameCount, '`NoImgPath`0'); this.ChangeArr(this.FrameDelay, this.AnimationFrameCount, 0); this.NowSettingCount = this.AnimationFrameCount; } } }