acdbcdda-443e-401a-9e32-a735c63ffd90.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. cc._RF.push(module, 'acdbc3aRD5AGp4ypzXGP/2Q', 'BgScroll');
  3. // res/effects/BgScroll.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 (b.hasOwnProperty(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 ShaderParamComponent = /** @class */ (function (_super) {
  27. __extends(ShaderParamComponent, _super);
  28. function ShaderParamComponent() {
  29. var _this = _super !== null && _super.apply(this, arguments) || this;
  30. _this.sprite = null;
  31. _this._material = null;
  32. _this._start = 0;
  33. _this.speed = 1;
  34. return _this;
  35. }
  36. ShaderParamComponent.prototype.onLoad = function () {
  37. this.sprite = this.getComponent(cc.Sprite);
  38. if (this.sprite) {
  39. this._material = this.sprite.getMaterial(0);
  40. }
  41. this.initParams();
  42. };
  43. ShaderParamComponent.prototype.initParams = function () {
  44. if (this.sprite && this._material && this.speed) {
  45. this._material.setProperty("speed", this.speed);
  46. }
  47. };
  48. ShaderParamComponent.prototype.update = function (dt) {
  49. // if (this.sprite) {
  50. // this._material = this.sprite.getMaterial(0);
  51. // }
  52. if (this.node.active && this._material) {
  53. if (this._material.getProperty("time", 0) != undefined) {
  54. this._material.setProperty('time', this._start);
  55. this._start += dt;
  56. }
  57. }
  58. };
  59. __decorate([
  60. property({ displayName: "速度" })
  61. ], ShaderParamComponent.prototype, "speed", void 0);
  62. ShaderParamComponent = __decorate([
  63. ccclass
  64. ], ShaderParamComponent);
  65. return ShaderParamComponent;
  66. }(cc.Component));
  67. exports.default = ShaderParamComponent;
  68. cc._RF.pop();