I have a cocos game that is running within a div element(850px * 500px) on my html page. I am using the cocos fullscreen API in my game and The cc.EGLView.getInstance().resizeWithBrowserSize(); has been set to true in my game. The issue is that when I resize the browser, my canvas doesn’t automatically resize, though when I escape from full screen mode the game automatically resizes to 850px*500px. Is it possible for the canvas to be resized on browser resize as well?(In spite of the CSS width and height properties of the div?)
The reason that your game is not responding to the browser resize event is that you use a fix sized container.
Your container #mygame is the frame for your game canvas, and in cocos2d, your game canvas will only be resized within the frame. While your window is the frame, the canvas will be resized with the window, but as you have a fix sized frame, then no matter how the window resize, your frame stay the same size, so your canvas won’t resize.
What you can do is to resize your #mygame frame with the window’s resize event. Then it will work.
setResizeCallback method not fire after rotaion in android device. When run in browser the working fine.
buth create apk with cross platform then event not call.
Bellow code , I have used.
cc.view.resizeWithBrowserSize(true);
cc.view.setResizeCallback(function() {
// Do things according to your need,
// e.g. change a resolution policy when user's mobile orientation changed.
var frameSize = cc.view.getFrameSize();
if(frameSize.width < frameSize.height)
{
cc.view.setDesignResolutionSize(width,height, cc.ResolutionPolicy.EXACT_FIT);
}
else
{
cc.view.setDesignResolutionSize(height,width, cc.ResolutionPolicy.EXACT_FIT);
}
});