Adaptation.js 608 B

1234567891011121314151617181920212223242526272829
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. m_bScale: {
  5. default: false,
  6. tooltip: "橫屏窄與比例,是否採用縮放?"
  7. }
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad:function () {
  11. var s1 = cc.view.getDesignResolutionSize();
  12. var s2 = cc.winSize;
  13. var scaleX = s2.width/s1.width;
  14. if(scaleX<1){
  15. if(this.m_bScale) this.node.scaleX = scaleX
  16. }else{
  17. this.node.width = s1.width*scaleX;
  18. }
  19. },
  20. // start () {
  21. // },
  22. // update (dt) {},
  23. });