feat: group 1.0.0
This commit is contained in:
35
assets/seripts/ui/Tipcontrol.ts
Normal file
35
assets/seripts/ui/Tipcontrol.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { _decorator, Component, Label, Node, tween, Vec3 } from "cc";
|
||||
import { EventDispatcher } from "../libs/EventDispatcher";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("TipControl")
|
||||
export class TipControl extends Component {
|
||||
//提示标签
|
||||
@property(Label)
|
||||
tipLabel: Label | null = null;
|
||||
start() {
|
||||
//默认位置,屏幕外
|
||||
this.node.setPosition(0, -1000);
|
||||
//监听tips msg事件
|
||||
EventDispatcher.getTarget().on(
|
||||
EventDispatcher.TIP_MSG,
|
||||
this.showTips,
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
//显示提示
|
||||
showTips(msg: string) {
|
||||
this.tipLabel.string = msg;
|
||||
tween(this.node)
|
||||
.to(0.2, { position: new Vec3(0, 0, 0) })
|
||||
.delay(1)
|
||||
.to(0.2, { position: new Vec3(0, 1000, 0) })
|
||||
.call(() => {
|
||||
this.node.setPosition(0, -1000);
|
||||
})
|
||||
.start();
|
||||
}
|
||||
|
||||
update(deltaTime: number) {}
|
||||
}
|
||||
Reference in New Issue
Block a user