Search code examples
javascripthtmlcanvasfullscreencocos2d-html5

Make a cocos HTML game go full screen by pressing a button within the canvas


I have an HTML game using the cocos 2D game engine and javascript. I have an image within the canvas, on clicking which I want the image to go full screen. Please don't confuse this question with doing this: http://jlongster.com/2011/11/21/canvas.html which I am able to reproduce just fine. The button is in the cocos canvas. Any help would be much appreciated.


Solution

  • So, I figured out the answer to my own question. The new Cocos-HTML5 has a nice API that makes your canvas full screen when you press a button:

    if(coordinates are from the touch area)
    {
        cc.Screen.getInstance().requestFullScreen(document.getElementById('<DIV ID in which your cocos canvas is embedded>'))
    }
    

    For more details check out: http://www.cocos2d-x.org/forums/19/topics/42564?r=42958#message-42958