720ea0383d3d81fb5096855341fef916a91a8f7e.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Component, Sprite, _decorator, _dec, _class, _crd, ccclass, property, FlashSprite;
  4. return {
  5. setters: [function (_cc) {
  6. _cclegacy = _cc.cclegacy;
  7. __checkObsolete__ = _cc.__checkObsolete__;
  8. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  9. Component = _cc.Component;
  10. Sprite = _cc.Sprite;
  11. _decorator = _cc._decorator;
  12. }],
  13. execute: function () {
  14. _crd = true;
  15. _cclegacy._RF.push({}, "a7a9eXWbUpJ3rONqlgUYCY/", "FlashSprite", undefined);
  16. __checkObsolete__(['Component', 'Material', 'Sprite', '_decorator']);
  17. ({
  18. ccclass,
  19. property
  20. } = _decorator);
  21. _export("default", FlashSprite = (_dec = ccclass('FlashSprite'), _dec(_class = class FlashSprite extends Component {
  22. constructor() {
  23. super(...arguments);
  24. this.duration = 0.5;
  25. this._median = 0;
  26. this._time = 0;
  27. this._material = null;
  28. }
  29. onLoad() {
  30. this._median = this.duration / 2; // 获取材质
  31. this._material = this.node.getComponent(Sprite).getMaterial(0); // 设置材质对应的属性
  32. this._material.setProperty("u_rate", 1);
  33. }
  34. update(dt) {
  35. if (this._time > 0) {
  36. this._time -= dt;
  37. this._time = this._time < 0 ? 0 : this._time;
  38. var rate = Math.abs(this._time - this._median) * 2 / this.duration;
  39. this._material.setProperty("u_rate", rate);
  40. }
  41. }
  42. clickFlash() {
  43. this._time = this.duration;
  44. }
  45. }) || _class));
  46. _cclegacy._RF.pop();
  47. _crd = false;
  48. }
  49. };
  50. });
  51. //# sourceMappingURL=720ea0383d3d81fb5096855341fef916a91a8f7e.js.map