fuhuo1.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const {ccclass, property} = cc._decorator;
  2. @ccclass
  3. export default class NewClass extends cc.Component {
  4. // LIFE-CYCLE CALLBACKS:
  5. onLoad () {
  6. this.node.getChildByName("cd").getChildByName("RankScene").active = false;
  7. this.node.getChildByName("zl").getChildByName("rePlay").active = false;
  8. this.node.getChildByName("fh").getChildByName("rePlay").active = true;
  9. }
  10. start () {
  11. }
  12. update (dt) {
  13. let self = this;
  14. let Ani;
  15. let Anistate;
  16. let PlayOver = false;
  17. let Countdown = this.node.getChildByName("fh").getChildByName("Countdown").getComponent(cc.Label);
  18. let time = parseInt(Countdown.string);
  19. let scheduler = cc.director.getScheduler();
  20. // scheduler.schedule(aniplayer,this,1,10,1,false);
  21. this.scheduleOnce(aniplayer,1);//完成使用schedule的情况下,提示warning的问题。
  22. /**
  23. * 结束页面的动画播放
  24. */
  25. function aniplayer(){
  26. let self = this;
  27. if(time>0){
  28. time--;
  29. }
  30. if(time==0){
  31. this.isScheduled = false;
  32. Ani = self.getComponent(cc.Animation);
  33. Anistate = Ani.play();
  34. Countdown.string = time.toString();
  35. self.node.getChildByName("cd").getChildByName("RankScene").active = true;
  36. self.node.getChildByName("zl").getChildByName("rePlay").active = true;
  37. self.node.getChildByName("fh").getChildByName("rePlay").active = false;
  38. scheduler.pauseTarget(this);
  39. PlayOver = true;
  40. }
  41. Countdown.string = time.toString();
  42. if(PlayOver){
  43. self.scheduleOnce(function(){
  44. scheduler.resumeTargets(self);
  45. scheduler.pauseAllTargets();
  46. },0.47);
  47. }
  48. }
  49. }
  50. }