ProgressAction.ts 750 B

12345678910111213141516171819202122232425
  1. import { _decorator, Component, Node, Sprite, UITransform } from 'cc';
  2. import { Global } from './Global';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('ProgressAction')
  5. export class ProgressAction extends Component {
  6. @property({ type: Node })
  7. level_progress: Node
  8. @property({ type: Node })
  9. particle: Node
  10. start() {
  11. }
  12. update(deltaTime: number) {
  13. let data = Global.cur_lvl_pin_move_num / Global.cur_lvl_pin_total;
  14. // console.log("data>>",data);
  15. let width = this.level_progress.getComponent(UITransform).contentSize.width;
  16. let add = width * data;
  17. this.particle.setPosition(width / 2 * -1 + add, 0);
  18. this.level_progress.getComponent(Sprite).fillRange = data;
  19. }
  20. }