123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
- "use strict";
- var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, SpriteFrame, Sprite, Game, _dec, _dec2, _class, _class2, _descriptor, _crd, ccclass, property, FrameAnimation;
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
- function _reportPossibleCrUseOfGame(extras) {
- _reporterNs.report("Game", "../game/Game", _context.meta, extras);
- }
- return {
- setters: [function (_unresolved_) {
- _reporterNs = _unresolved_;
- }, function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Component = _cc.Component;
- SpriteFrame = _cc.SpriteFrame;
- Sprite = _cc.Sprite;
- }, function (_unresolved_2) {
- Game = _unresolved_2.Game;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "dba31tmjWBBjISTFQZgGviW", "FrameAnimation", undefined);
- __checkObsolete__(['_decorator', 'Component', 'SpriteFrame', 'Sprite']);
- ({
- ccclass,
- property
- } = _decorator);
- _export("FrameAnimation", FrameAnimation = (_dec = ccclass('FrameAnimation'), _dec2 = property({
- type: [SpriteFrame],
- tooltip: "播放的帧动画类"
- }), _dec(_class = (_class2 = class FrameAnimation extends Component {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "playSFArray", _descriptor, this);
- //每一帧的时长
- this.duration = 0.1;
- //播放完后的回调函数
- this.endFunc = null;
- //播放到第几帧回调函数
- this.playIdxFunc = null;
- //播放到第几帧回调函数
- this.idx = 0;
- //是否播放帧动画
- this.isPlayAnim = false;
- //记录已经播放的时间
- this.playTime = 0;
- //是否循环播放
- this.loop = true;
- //播放的精灵 播放的帧动画
- this.currnSprite = null;
- //播放帧图片数据
- this.playSFs = [];
- }
- /**
- * 播放帧动画
- * @param noSp
- * @param clipSFs
- * @param isLoop
- * @param callback
- */
- play(s, loop, endf, playFun, idx) {
- if (s === void 0) {
- s = this.duration;
- }
- if (loop === void 0) {
- loop = true;
- }
- if (endf === void 0) {
- endf = () => {};
- }
- if (playFun === void 0) {
- playFun = () => {};
- }
- if (idx === void 0) {
- idx = 0;
- }
- if (!loop) {
- if (this.isPlayAnim) {
- return;
- }
- }
- if (this.playSFArray.length > 0) {
- this.playSFs = this.playSFArray;
- }
- if (!this.currnSprite) {
- this.currnSprite = this.node.getComponent(Sprite);
- }
- if (this.playSFs.length > 0) {
- this.isPlayAnim = true;
- this.playTime = 0;
- this.loop = loop;
- this.duration = s / this.playSFs.length;
- this.endFunc = endf;
- this.idx = idx;
- this.currnSprite.spriteFrame = this.playSFs[0];
- this.playIdxFunc = playFun;
- } else {
- this.isPlayAnim = false;
- }
- }
- update(deltaTime) {
- if (!this.isPlayAnim || !this.currnSprite || !this.currnSprite.node.active) {
- return;
- }
- var g = (_crd && Game === void 0 ? (_reportPossibleCrUseOfGame({
- error: Error()
- }), Game) : Game).I;
- if (g && g.isPause) {
- return;
- } //累计时间,通过时间计算应该取哪一张图片展示
- this.playTime += deltaTime;
- var index = Math.floor(this.playTime / this.duration);
- if (this.loop) {
- // 循环播放
- if (index >= this.playSFs.length) {
- index -= this.playSFs.length;
- this.playTime -= this.duration * this.playSFs.length;
- }
- this.currnSprite.spriteFrame = this.playSFs[index];
- } else {
- //播放一次
- if (index >= this.playSFs.length) {
- var _this$endFunc;
- this.isPlayAnim = false; //如果有回调函数的处理,则调用回调函数
- (_this$endFunc = this.endFunc) == null || _this$endFunc.call(this);
- } else {
- this.currnSprite.spriteFrame = this.playSFs[index];
- }
- if (this.playIdxFunc && this.idx == index) {
- this.playIdxFunc();
- }
- }
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "playSFArray", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return [];
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=09779d9a3409a634b698261612af23d794d71355.js.map
|