const { ccclass, property } = cc._decorator; @ccclass export default class animationFrame extends cc.Component { private intervalTime: number = 0.01;// _间隔时间: 1, private currentIntervalTime: number = 0;// 当前间隔时间: 1, private time: number = 1;// 最小间隔: 1, private changeIntervalTime: number = 0.01;//切换间隔时间: 0.1, private flags: boolean = false; @property([cc.SpriteFrame]) public textureArr: cc.SpriteFrame[] = [];// 动画帧组: [cc.SpriteFrame], private _index: number = 0; // LIFE-CYCLE CALLBACKS: // onLoad () {} start() { } update(dt) { if (!this.flags) { this.currentIntervalTime -= dt; if (this.currentIntervalTime <= 0) { this.flags = true; } } else { this.time += dt; if (this.time >= this.changeIntervalTime) { if (this._index < this.textureArr.length) { this.node.getComponent(cc.Sprite).spriteFrame = this.textureArr[this._index]; this._index++; } else { this._index = 0; this.currentIntervalTime = this.intervalTime; this.flags = false; } this.time = 0; } } } }