Over.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName from "./EventName/EventName";
  8. import LocalData from "./LocalData";
  9. import MyComponent from "./Template/MyComponent";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class Over extends MyComponent {
  13. @property(cc.SpriteFrame)
  14. Sp: cc.SpriteFrame[] = [];
  15. @property(cc.Label)
  16. Hight: cc.Label = null;
  17. @property(cc.Label)
  18. label: cc.Label = null;
  19. onLoad() {
  20. this.regEvent(EventName.Over, this.Over, this)
  21. }
  22. Over() {
  23. this.node.opacity = 255
  24. this.label.string = this.Hight.string
  25. if (LocalData.getInstance().getOverCount() == 0) {//首次通关
  26. this.getComponent(cc.Sprite).spriteFrame = this.Sp[0]
  27. } else {
  28. this.getComponent(cc.Sprite).spriteFrame = this.Sp[1]
  29. }
  30. }
  31. // update (dt) {}
  32. }