Cc.Screen -> getInstance does not return the instance + FIX

first: excellent work guys on cocos2dhtml5.
of course I am posting for a problem;-)

I tried to use the cc.Screen API to go/exit fullscreen.

I could not get the instance of cc.Screen with cc.Screen.getInstance(), looked into the source code and found out getInstance() does not store the instance anywhere thus returns undefined and tries to recreate/init it at each call ?

here is the source part I modified to make that work:
as I don’t know much of how instances are kept in cocos, this might not be the ideal solution but here is what I modified:

in platform/CCScreen.js

cc.Screen.getInstance = function () {
if (!this.*instance){
var screen = new cc.Screen;
screen.init;
// ADDED THIS NEXT LINE
this.*instance = screen;
}
return this._instance;
};

or am I wrong here ?

Nick

Hi Nick,

Thanks for your noticing, this issue had been fixed at: https://github.com/cocos2d/cocos2d-html5/pull/1269

Best regards
David

k cool thx.
guess It was submitted after the latest 2.2.1 release that’s why I missed it.
I need to get better with github :wink: