toast.ts 503 B

12345678910111213141516
  1. import { _decorator, Component, Label, Node, tween, UIOpacity } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('toast')
  4. export class toast extends Component {
  5. @property(Node) img_mask: Node = null;
  6. @property(Node) lab_text: Node = null;
  7. public show(text: string = "", opacity: number = 175) {
  8. this.img_mask.getComponent(UIOpacity).opacity = opacity;
  9. this.lab_text.getComponent(Label).string = text;
  10. tween(this.node).delay(2).hide().start()
  11. }
  12. }