TextNoticeView.ts 736 B

123456789101112131415161718192021222324252627282930
  1. import { _decorator, Component, Node, LabelComponent, SpriteComponent } from 'cc';
  2. import { NoticeViewScript } from '../../../engines/notices/NoticeViewScript';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('TextNoticeView')
  5. export class TextNoticeView extends NoticeViewScript {
  6. @property({
  7. type:LabelComponent
  8. })
  9. label:LabelComponent=null;
  10. @property({
  11. type:SpriteComponent
  12. })
  13. background:SpriteComponent=null;
  14. start():void{
  15. }
  16. OnStartMove():void{
  17. this.label.string=this.data;
  18. }
  19. update(dt:number):void{
  20. super.update(dt);
  21. this.background.node.width=this.label.node.width+24;
  22. this.background.node.height=this.label.node.height;
  23. }
  24. }