const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
onLoad()
{
let ratio = cc.winSize.height / cc.winSize.width;
ratio = parseInt(ratio.toFixed(1));
// console.log("mylog ratio = " + ratio);
if(ratio <= 1.3)
{
// console.log("mylog match height");
this.node.getComponent(cc.Canvas).fitHeight = true;
this.node.getComponent(cc.Canvas).fitWidth = false;
}else
{
// console.log("mylog match width");
this.node.getComponent(cc.Canvas).fitWidth = true;
this.node.getComponent(cc.Canvas).fitHeight= false;
}
}
}
网友评论