import { _decorator,Component,Vec3,tween,Label } from "cc"; import { GameMng } from "../GameMng"; import { UIManager } from "./UIManager"; const {ccclass, property} = _decorator; @ccclass export default class UITips extends Component { private pos:Vec3=new Vec3(); private toscale:Vec3=new Vec3(); private targetworldPos:Vec3=new Vec3(); private isPlayAnim:boolean=false; private startScale:Vec3=new Vec3(1,1,1); private onestepScale:Vec3=new Vec3(1,1,1); private randPos:Vec3=new Vec3(); playAnim(){ this.isPlayAnim=true; this.node.setPosition(this.pos); this.node.setScale(this.startScale); tween(this.node) .to(0.6, { scale: new Vec3(this.onestepScale.x,this.onestepScale.y,0) }, { easing: 'smooth' }) .delay(0.3) .hide() .call(() => { this.isPlayAnim = false; this.node.destroy(); }) .start(); } static show(msg:string,worldpos?:Vec3){ //return; let gnode = UIManager.AddPrefab(GameMng.Instance.uitips) let uitips = gnode.getComponent(UITips); uitips.getComponentInChildren(Label).string = msg; if(worldpos) uitips.targetworldPos = worldpos.clone(); uitips.randPos.y=200; uitips.randPos.add(uitips.targetworldPos); uitips.playAnim(); } update(dt:number){ if(this.isPlayAnim){ // this.pos=this.targetworldPos; // this.targetworldPos.lerp(this.randPos, 0.05); // this.node.setPosition(this.pos); this.targetworldPos.y+=dt*200; this.node.setPosition(this.targetworldPos) } } }