import bundleManager from "../../../manager/bundleManager"; const { ccclass } = cc._decorator; /**开场动画播放类 */ @ccclass export default class UIStoryAni extends cc.Component { /**图片组 */ private pics: cc.SpriteFrame[] = [null, null, null]; callBack: Function; init(cbk: Function) { this.callBack = cbk; for (let i = 1; i <= 3; i++) { bundleManager.setBundleFrame('UI', 'main/story/' + i, null, (sf: cc.SpriteFrame) => { this.pics[i - 1] = sf; this.checkDone(cbk); }); } } /**检测初始是否化完成 */ checkDone(cbk: Function) { for (let i = 0; i < 3; i++) { if (this.pics[i] == null) { return; } } let sp = this.node.getComponent(cc.Sprite); let i = 0; sp.spriteFrame = this.pics[i]; i++; this.schedule(() => { if (i < 3) { sp.spriteFrame = this.pics[i]; i++; } else { cbk(this.node); //this.node.destroy(); } }, 2, 2); } skip_btn() { if (this.callBack) { this.callBack(this.node); } } }