Multi Device Resolution

So far our game is rather a portrait game, that needs to be said first. Its not supposed to run in landscape.
Its supposed to run on iOs and Android, Thus a number of slightly different resolutions need to be supported.

I used the cocos editor to set up some scenes and layers and used its pinning methods.
But pinning is needless if it does not react to different game sizes.

i came across this [topic][1]
[1]: Multi resolution Support for Cocos Studio 2 problem solved! :D
But it was not to helpfull.

i tried something like this:
var size = cc.winSize;
this.guiLayer = new GUILayer(); // where the layer comes from a cocos studio file
this.guiLayer.setContentSize(size);
this.addChild(this.guiLayer);

that also doesn´t work.

So, how do you get cocos studio elements with pinning to react to different device sizes then?

Main.js is setup like this (and yes i tried other resolution policys as well):
cc.game.onStart = function(){
cc.view.adjustViewPort(true);
cc.view.setDesignResolutionSize(768, 1024, cc.ResolutionPolicy.FIXED_HEIGHT);
cc.view.resizeWithBrowserSize(true);
//load resources
cc.LoaderScene.preload(g_resources, function () {
cc.director.runScene(new GameScene());
}, this);
};

1 Like

ok, for my own record i found the following so far:

let´s say you subclassed stuff to load from cocos studio files and do something with it.
in its constructor do this:

ctor:function () {
//////////////////////////////
// 1. super init first
this._super();
// ask the window size
var size = cc.director.getVisibleSize();

    var guiscene = ccs.load(res.guilayer_json);
    guiscene.node.setContentSize(size);

    ccui.helper.doLayout(guiscene.node);
    this.addChild(guiscene.node);

}

Now, and only now, your pinned elements stay in place.
I guess you have to do this for every call to your cocos studio base elements. be it scenes or be it Layers.

I don´t know if this is the right approach but so far it worked.

1 Like