FrameBg.ts 771 B

123456789101112131415161718192021222324252627282930313233
  1. import { _decorator, Component, Node, sys, Widget } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('FrameBg')
  4. export class FrameBg extends Component {
  5. protected onLoad() {
  6. // 判断平台
  7. if (sys.isMobile) {
  8. // 手机端添加Widget组件
  9. const widget = this.node.addComponent(Widget);
  10. widget.isAlignLeft = true;
  11. widget.isAlignRight = true;
  12. widget.isAlignTop = true;
  13. widget.isAlignBottom = true;
  14. widget.left = 0;
  15. widget.right = 0;
  16. widget.top = 0;
  17. widget.bottom = 0;
  18. widget.updateAlignment();
  19. }
  20. // PC端不做处理
  21. }
  22. start() {
  23. }
  24. update(deltaTime: number) {
  25. }
  26. }