cc.Class({
    extends: cc.Component,

    properties: {
    },

    // use this for initialization
    onLoad: function () {
        this.fit_canvas();
    },

   
    fit_canvas: function () {
      var self = this;
      let c = this.node.getComponent(cc.Canvas);
        c.fitHeight = true;
        c.fitWidth = false;
        let width = c.designResolution.width;

        let h = width * cc.winSize.height / cc.winSize.width;

        c.designResolution = new cc.Size(width, h);
        this.node.setContentSize(width, h);

 

 

        // 适配解决方案
        let _canvas = cc.Canvas.instance;
        // 设计分辨率比
        let _rateR = _canvas.designResolution.height/_canvas.designResolution.width;
        // 显示分辨率比
        let _rateV = cc.winSize.height/cc.winSize.width;
        console.log("winSize: rateR: "+_rateR+" rateV: "+_rateV);
        if (_rateV > _rateR)
        {
            _canvas.fitHeight = false;
            _canvas.fitWidth = true;
            console.log("winSize: fitWidth");
        }
        else
        {
            _canvas.fitHeight = true;
            _canvas.fitWidth = false;
            console.log("winSize: fitHeight");
        }
     }

});
