BindPhoneLayer.js 930 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var baseLayer = require('BaseLayer');
  2. import SoundMgr from "../base/SoundMgr";
  3. cc.Class({
  4. extends: baseLayer,
  5. properties: {
  6. labPhone: cc.EditBox,
  7. labCode: cc.EditBox,
  8. maskCode: cc.Node,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. // onLoad () {},
  12. start () {
  13. this.codeTime = 60;
  14. },
  15. onClickCode(){
  16. SoundMgr.playClick();
  17. this.maskCode.active = true;
  18. this.refreshMaskS();
  19. this.schedule(()=>{
  20. this.refreshMaskS();
  21. }, 1, cc.macro.REPEAT_FOREVER)
  22. },
  23. refreshMaskS(){
  24. this.maskCode.getChildByName('lab').getComponent(cc.Label).string = `${this.codeTime}s`;
  25. this.codeTime -= 1;
  26. if(this.codeTime < 0){
  27. this.codeTime = 60;
  28. this.unscheduleAllCallbacks();
  29. this.maskCode.active = false;
  30. }
  31. },
  32. onClickSubmit(){
  33. SoundMgr.playClick();
  34. },
  35. });