美文网首页
Creator适配屏幕

Creator适配屏幕

作者: Albert_d37d | 来源:发表于2021-06-09 14:42 被阅读0次

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;

        }

    }

}

相关文章

网友评论

      本文标题:Creator适配屏幕

      本文链接:https://www.haomeiwen.com/subject/lbeeeltx.html