I have a game that I have built in Cocos2d-html5 3.x and am running into issues on Chrome on android devices with high resolution screens (specifically my Nexus 5 and Galaxy S4).
The Nexus 5 returns a device pixel ratio of 3, but a backing store pixel ratio of 1.
Chrome appears to be shrinking down my high resolution assets and then blowing them back up 3x with results in severe quality loss. Firefox on Android, and all iOS browsers do not experience the problem. (backing store pixel ration == device pixel ratio).
Has anyone experienced this before and is there a known solution?
A solution has been found thanks to a colleague of mine who noticed that the version of Cocos2d-html5 I am using only enables retina display on OSX or iOS devices.
Making the following change resolves the issues on all affected platforms.
Looks like I’m experiencing a very similar issue. Nexus 5 returns a viewport resolution of just 598 x 360.
Where did you make that change? What did you have to set your canvas / design resolution / resolution policy to in order for the game to be rendered in HiRes?
You are right, we do active retina display only on iOS devices. But you don’t really need to modify the engine. You can just enable retina in the main.js
cc.game.onStart = function(){
// Add this line
cc.view.enableRetina(true);
cc.view.adjustViewPort(true);
cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL);
cc.view.resizeWithBrowserSize(true);
//load resources
cc.LoaderScene.preload(g_resources, function () {
cc.director.runScene(new HelloWorldScene());
}, this);
};
cc.game.run();
The reason we only active it on iOS is that we observed the behavior and iOS seems running really good under retina mode. But on many Android devices, once we activate retina display, the performance drops significantly.