import { UIViewID } from '@scripts/define/UIDefine'; import { UICloseReason } from '@scripts/framework/ui/UILayer'; import { UIView } from '@scripts/framework/ui/UIView'; import { _decorator, Component, Node, Tween, tween, UIOpacity } from 'cc'; const { ccclass, property } = _decorator; @ccclass('LoadingView') export class LoadingView extends UIView { readonly viewId = UIViewID.LoadingView; @property(UIOpacity) uiOpacity: UIOpacity; @property(Node) circleNode: Node = null; protected onOpen({ delay }): void | Promise { Tween.stopAllByTarget(this.circleNode); tween(this.circleNode).by(0.5, { angle: -200 }).repeatForever().start(); if (delay > 0) { this.uiOpacity.opacity = 0; Tween.stopAllByTarget(this.uiOpacity); tween(this.uiOpacity).to(0.2, { opacity: 255 }).delay(delay).start(); } } protected onClose(_reason: UICloseReason): void | Promise { Tween.stopAllByTarget(this.circleNode); Tween.stopAllByTarget(this.uiOpacity); } }