I've been looking for a way to make my Cocos2D-JS app go into fullscreen mode, but there doesn't seem to be much documentation on Cocos2D-JS (or Cocos2D-x-js as some seem to call it.) This app is to be exported into a Windows Desktop platform (Win32), and so fullscreen mode should work there as well.

I checked the Cocos2D-JS Online API and found cc.screen, which has a method called requestFullScreen, so I tried this:

cc.screen.requestFullScreen(document.documentElement, function() { cc.log('Requesting full screen...'); } );

However, this didn't work on either of the platforms I tested it on (web browser and win32). Since document does not exist when you export the app into win32, I then tried changing it for cc._canvas:

cc.screen.requestFullScreen(cc._canvas, function() { cc.log('Requesting full screen...'); } );

But this did not work either. Is there a way to make the app run in fullscreen mode?

PD: My apologies for any wrong tags I may have included to this question. I added the ones I thought were related to this problem.


I was able to make the deployed cocos2d-js Win32 app run in fullscreen mode by modifying the AppDelegate.cpp file (located in frameworks/runtime-src/Classes/AppDelegate.cpp).

  1. Inside the AppDelegate.cpp find method applicationDidFinishLoading

  2. Within method applicationDidFinishLoading, look for this line:

    glview = cocos2d::GLViewImpl::createWithRect("MyAppName", Rect(0,0,900,640));
  3. Call createWithFullScreen instead of createWithRect, and remove second argument (which sets the window size in window mode):

    glview = cocos2d::GLViewImpl::createWithFullScreen("MyAppName");
  4. Compile/Deploy the app using cocos compile -p win32, cocos deploy -p win32 -m debug, or cocos run -p win32.

And that's it. :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.