BtnClick.ts 808 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class BtnClick extends cc.Component {
  10. // LIFE-CYCLE CALLBACKS:
  11. // onLoad () {}
  12. @property(cc.Button)
  13. btn:cc.Button = null
  14. start () {
  15. }
  16. click(){
  17. this.btn.interactable = false
  18. this.scheduleOnce(()=>{
  19. if(cc.isValid(this.btn)){
  20. this.btn.interactable = true
  21. }
  22. },1)
  23. }
  24. // update (dt) {}
  25. }