42 lines
1000 B
TypeScript
42 lines
1000 B
TypeScript
import { _decorator, Component, Label, Node, tween, UIOpacity, v3 } from 'cc';
|
|
import Utils from '../../Main/Common/Utils';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('promptItem')
|
|
export class promptItem extends Component {
|
|
|
|
private _nodeTab:any = {}
|
|
private autoHideTime:number = 0
|
|
|
|
protected onLoad(): void {
|
|
Utils.parseNode(this.node, this._nodeTab)
|
|
}
|
|
start() {
|
|
tween(this.node)
|
|
.by(2, { position: v3(0, 150, 0) })
|
|
.start()
|
|
|
|
let opa = this.node.getComponent(UIOpacity)
|
|
tween(opa)
|
|
.delay(0.5)
|
|
.to(2, { opacity: 0 })
|
|
.start()
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
this.autoHideTime += deltaTime
|
|
if (this.autoHideTime > 2) {
|
|
this.autoHideTime = 0
|
|
this.node.removeFromParent()
|
|
}
|
|
}
|
|
|
|
//设置文本显示
|
|
public setLabel(lab:string) {
|
|
let txt:Label = this._nodeTab.txt.getComponent(Label)
|
|
txt.string = lab
|
|
}
|
|
}
|
|
|
|
|