LoadingView.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { UIViewID } from '@scripts/define/UIDefine';
  2. import { UICloseReason } from '@scripts/framework/ui/UILayer';
  3. import { UIView } from '@scripts/framework/ui/UIView';
  4. import { _decorator, Component, Node, Tween, tween, UIOpacity } from 'cc';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('LoadingView')
  7. export class LoadingView extends UIView {
  8. readonly viewId = UIViewID.LoadingView;
  9. @property(UIOpacity)
  10. uiOpacity: UIOpacity;
  11. @property(Node)
  12. circleNode: Node = null;
  13. protected onOpen({ delay }): void | Promise<void> {
  14. Tween.stopAllByTarget(this.circleNode);
  15. tween(this.circleNode).by(0.5, { angle: -200 }).repeatForever().start();
  16. Tween.stopAllByTarget(this.uiOpacity);
  17. this.uiOpacity.opacity = delay > 0 ? 0 : 255;
  18. if (delay > 0) {
  19. tween(this.uiOpacity).to(0.2, { opacity: 255 }).delay(delay).start();
  20. }
  21. }
  22. protected onClose(_reason: UICloseReason): void | Promise<void> {
  23. Tween.stopAllByTarget(this.circleNode);
  24. Tween.stopAllByTarget(this.uiOpacity);
  25. }
  26. }