FullScene.ts 446 B

123456789101112131415161718192021
  1. const {ccclass, property} = cc._decorator;
  2. /**
  3. * 尺寸布满全屏
  4. */
  5. @ccclass
  6. export default class FullScene extends cc.Component {
  7. onLoad () {
  8. let d1 = cc.winSize.height/cc.winSize.width;
  9. let d2 = this.node.height/this.node.width;
  10. if(d1 > d2){
  11. this.node.scale = cc.winSize.height/this.node.height;
  12. }else{
  13. this.node.scale = cc.winSize.width/this.node.width;
  14. }
  15. }
  16. }