ShowTip.ts 669 B

12345678910111213141516171819202122232425262728
  1. import { _decorator, Component, Node, Label, tween } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('ShowTip')
  4. export class ShowTip extends Component {
  5. public static instance: ShowTip = null;
  6. start() {
  7. ShowTip.instance = this;
  8. tween(this.node).hide().start();
  9. this.node.getComponent(Label).string = '0';
  10. this.node.setScale(2,2);
  11. }
  12. update(deltaTime: number) {
  13. }
  14. public Show_Tip(str: string) {
  15. tween(this.node).show().start();
  16. this.node.getComponent(Label).string = str;
  17. setTimeout(() => {
  18. tween(this.node).hide().start();
  19. }, 1000);
  20. }
  21. }