18f9f729-d90e-496b-9ef1-84ad78dcb4bf.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. cc._RF.push(module, '18f9fcp2Q5Ja57xhK143LS/', 'animationFrame');
  3. // Script/prop/animationFrame.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  26. var animationFrame = /** @class */ (function (_super) {
  27. __extends(animationFrame, _super);
  28. function animationFrame() {
  29. var _this = _super !== null && _super.apply(this, arguments) || this;
  30. _this.intervalTime = 0.01; // _间隔时间: 1,
  31. _this.currentIntervalTime = 0; // 当前间隔时间: 1,
  32. _this.time = 1; // 最小间隔: 1,
  33. _this.changeIntervalTime = 0.01; //切换间隔时间: 0.1,
  34. _this.flags = false;
  35. _this.textureArr = []; // 动画帧组: [cc.SpriteFrame],
  36. _this._index = 0;
  37. return _this;
  38. }
  39. // LIFE-CYCLE CALLBACKS:
  40. // onLoad () {}
  41. animationFrame.prototype.start = function () {
  42. };
  43. animationFrame.prototype.update = function (dt) {
  44. if (!this.flags) {
  45. this.currentIntervalTime -= dt;
  46. if (this.currentIntervalTime <= 0) {
  47. this.flags = true;
  48. }
  49. }
  50. else {
  51. this.time += dt;
  52. if (this.time >= this.changeIntervalTime) {
  53. if (this._index < this.textureArr.length) {
  54. this.node.getComponent(cc.Sprite).spriteFrame = this.textureArr[this._index];
  55. this._index++;
  56. }
  57. else {
  58. this._index = 0;
  59. this.currentIntervalTime = this.intervalTime;
  60. this.flags = false;
  61. }
  62. this.time = 0;
  63. }
  64. }
  65. };
  66. __decorate([
  67. property([cc.SpriteFrame])
  68. ], animationFrame.prototype, "textureArr", void 0);
  69. animationFrame = __decorate([
  70. ccclass
  71. ], animationFrame);
  72. return animationFrame;
  73. }(cc.Component));
  74. exports.default = animationFrame;
  75. cc._RF.pop();