HotUpdateTipLabel.js 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. cc.Class({
  2. extends: cc.Component,
  3. editor: {
  4. menu: 'Launch/HotUpdateTipLabel'
  5. },
  6. properties: {
  7. deltaTime: cc.Float
  8. },
  9. onEnable () {
  10. this._count = 0;
  11. this._default = '更新中';
  12. let label = this.node.getComponent(cc.Label);
  13. this.schedule(() => {
  14. let index = this._count % 3;
  15. cc.log('index ' + index);
  16. label.string = this._getLabelStr(index);
  17. this._count += 1;
  18. if (this._count > 3) {
  19. this._count = 0;
  20. }
  21. }, this.deltaTime);
  22. },
  23. onDisable () {
  24. this.unscheduleAllCallbacks();
  25. },
  26. _getLabelStr (index) {
  27. switch (index) {
  28. case 0:
  29. return this._default + '.';
  30. case 1:
  31. return this._default + '..';
  32. case 2:
  33. return this._default + '...';
  34. }
  35. }
  36. });