Tip.ts 568 B

12345678910111213141516171819202122
  1. import { _decorator, Animation, Component, Label } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('Tip')
  4. export class Tip extends Component {
  5. private _animation: Animation = null;
  6. protected onLoad(): void {
  7. this._animation = this.node.getComponent(Animation);
  8. }
  9. start() {
  10. this._animation.once(Animation.EventType.FINISHED,()=>{
  11. this.node.removeFromParent();
  12. this.node.destroy();
  13. })
  14. }
  15. setContent(content: string){
  16. this.node.getComponent(Label).string = content;
  17. }
  18. }