TipsAction.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { _decorator, Component, Label, Node, tween, Vec3 } from 'cc';
  2. import { Clips } from './Enums';
  3. import { AudioMgr } from './AudioMgr';
  4. import { Global } from './Global';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('TipsAction')
  7. export class TipsAction extends Component {
  8. @property({type:Label})
  9. level_label:Label = null;
  10. msg:string[] = [];
  11. running = false;
  12. start() {
  13. this.set_default();
  14. }
  15. set_default(){
  16. this.node.setPosition(0,-1000)
  17. }
  18. update(deltaTime: number) {
  19. }
  20. public show(str:string){
  21. this.msg.push(str);
  22. // console.log("TipsAction>>>",str,this.level_label);
  23. if(!this.running){
  24. this.play();
  25. }
  26. }
  27. private play(){
  28. let self = this;
  29. if(self.msg.length == 0){
  30. self.running = false;
  31. return;
  32. }
  33. self.running = true;
  34. self.level_label.string = self.msg.shift();
  35. self.set_default();
  36. tween(self.node)
  37. .to(0.35,{position:new Vec3(0,0,0)},Global.our_easing)
  38. .delay(1)
  39. .to(0.1,{position:new Vec3(0,1000,0)},Global.our_easing)
  40. .call(()=>{
  41. AudioMgr.ins.playSound(Clips.reng);
  42. // this.set_default();
  43. self.play();
  44. })
  45. .start();
  46. }
  47. }