NoticeLabel.ts 685 B

12345678910111213141516171819202122232425262728293031
  1. import { _decorator, Color, Component, Label, Node } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. const tmpColor = new Color();
  4. @ccclass('NoticeLabel')
  5. export class NoticeLabel extends Component {
  6. private _label:Label;
  7. protected onLoad(): void {
  8. this._label = this.getComponent(Label);
  9. }
  10. public get alpha(){
  11. return this._label.color.a;
  12. }
  13. public set string(str:string){
  14. this._label.string = str;
  15. }
  16. public get string(){
  17. return this._label.string;
  18. }
  19. public set alpha(value:number){
  20. tmpColor.set(this._label.color);
  21. tmpColor.a = value;
  22. this._label.color = tmpColor;
  23. }
  24. }