LogoShader.ts 668 B

1234567891011121314151617181920212223242526272829
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class LogoShader extends cc.Component {
  4. @property({type: cc.Sprite})
  5. private sp: cc.Sprite = null;
  6. private mat_logo: cc.MaterialVariant = null;
  7. private time: number = 0;
  8. onLoad(){
  9. this.mat_logo = this.sp.getMaterial(0);
  10. this.time = this.mat_logo.getProperty('sys_time', 0);
  11. }
  12. update(dt)
  13. {
  14. this.time += 0.02;
  15. let t = this.mat_logo.getProperty('sys_time', 0);
  16. this.mat_logo.setProperty('sys_time', this.time);
  17. if(this.time>= 4)
  18. {
  19. this.time = 0;
  20. }
  21. }
  22. }