Jump to content

Cannot reproduce fullscreen.js from examples.


taeb
 Share

Recommended Posts

My game's main menu has a fullscreen button while in windowed mode, and (hopefully) a "exit fullscreen"-button when in fullscreen. However I can't seem to even reproduce this (with Phaser v2.6.1) example on my own web server, which makes it possible to exit fullscreen by clicking anywhere. Any known bugs/workarounds about this?

Right now my code is something like this:

function init() {
    game.scale.scaleMode = Phaser.ScaleManager.NO_SCALE;
    game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
}

function create() {
    if (game.scale.isFullScreen)
    {
        var button_normalscreen = buildButton(//yadayada, call function goNormal on click);
    }
    else
    {
        var button_fullscreen = buildButton(//yadayada, call function goFull on click);
    }
}

function goFull() {
    game.scale.startFullScreen;
}

function goNormal() {
    game.scale.stopFullScreen;
}

Without the if-else the game fullscreens (without the replaced button) just fine, but I can't exit fullscreen by clicking the button again, even with this function from the example:

function goFullNormal() {
    if (game.scale.isFullScreen)
    {
        game.scale.stopFullScreen();
    }
    else
    {
        game.scale.startFullScreen(false);
    }
}

I read something about cancelFullScreen, but it doesn't seem to make a difference.

This is the first time I'm programming in JavaScript, I'm more acclimitized to MATLAB and such, so bear with me :)

Link to comment
Share on other sites

First of all we don't know what buildButton does.

Second of all, fullscreen works, you need to set it to get triggered on an event. With the create function only running once, your only creating the button when starting the game and it will not generate the second button, ever.

You can try just updating the button when fullscreen gets enabled and vice versa.

button.onDown.add(gofull, this);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...