slider_progress.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. },
  14. // LIFE-CYCLE CALLBACKS:
  15. onLoad() {
  16. this.slider = this.getComponent(cc.Slider);
  17. this.progressbar = this.getComponent(cc.ProgressBar);
  18. if (this.slider == null || this.progressbar == null) {
  19. return;
  20. }
  21. this.progressbar.progress = this.slider.progress;
  22. let self = this;
  23. this.slider.node.on('slide', function (event) {
  24. this.progressbar.progress = this.slider.progress;
  25. }, this);
  26. },
  27. start() {
  28. },
  29. onSetProcgress(value) {
  30. if (this.slider)
  31. this.slider.progress = value;
  32. if (this.progressbar)
  33. this.progressbar.progress = value;
  34. }
  35. // update (dt) {},
  36. });