ShowTipsItem.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { ItemRender } from "../../../../frameWork/fgui/ListUtil";
  2. export class ShowTipsItem extends ItemRender{
  3. private _tipsLabel:fgui.GLabel;
  4. private bUsing:boolean;
  5. private stayTime:number; // 保持不渐变的时间
  6. private playAniTime:number;
  7. private movePosY:number;
  8. protected onConstruct(): void {
  9. this._tipsLabel = this.getChild("TipsLabel").asLabel;
  10. this.stayTime = 0.35;
  11. this.playAniTime = 1;
  12. this.movePosY = -100;
  13. }
  14. setData(data: any, index?: number, param?: any) {
  15. this.ShowTipsUI(data.tips, data.callback);
  16. }
  17. private ShowTipsUI(tips:string, callback:()=>void){
  18. this.bUsing = true;
  19. this.node.y = -490;
  20. this._tipsLabel.text = tips;
  21. this.visible = true;
  22. cc.tween(this.node).delay(this.stayTime).to(this.playAniTime,{position:cc.v3(this.node.x, this.node.y - this.movePosY,0)})
  23. .call(()=>{
  24. this.bUsing = false;
  25. this.visible = false;
  26. //改变完成回调
  27. if (callback){
  28. callback();
  29. }
  30. }).start();
  31. this.node.opacity = 255;
  32. cc.tween(this.node).to(this.playAniTime,{opacity:125}).start();
  33. }
  34. public IsUsing(){
  35. return this.bUsing;
  36. }
  37. public ResetUI(){
  38. this.bUsing = false;
  39. this.visible = false;
  40. }
  41. }