So I tried to port the code from this post to CC v3:
https://discuss.cocos2d-x.org/t/tutorial-responsive-layout/50885
This is the code from the post:
makeResponsive() {
let canvas = this.node.getComponent(cc.Canvas);
let deviceResolution = cc.view.getFrameSize();
// calculte design ratio
let desiredRatio = canvas.designResolution.width / canvas.designResolution.height;
// calculte device ratio
let deviceRatio = deviceResolution.width / deviceResolution.height;
if (deviceRatio >= desiredRatio) {
canvas.fitHeight = true;
canvas.fitWidth = false;
} else if (deviceRatio < desiredRatio) {
canvas.fitHeight = false;
canvas.fitWidth = true;
}
},
onLoad() {
this.makeResponsive();
},
which all went fine, but I can’t find an equivalent in the new API to this part :
canvas.fitHeight = true;
canvas.fitWidth = false;
It’s not on canvas
, not on view
and it seems it’s also nowhere else.
Is this deprecated? Is there another way? Did I miss something?
Thanks.