Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better fullscreen module? #33

Open
kittykatattack opened this issue Mar 27, 2015 · 2 comments
Open

A better fullscreen module? #33

kittykatattack opened this issue Mar 27, 2015 · 2 comments
Assignees

Comments

@kittykatattack
Copy link
Owner

Right now Ga has a very simple way of launching a game in fullscreen mode (Using the WHATWG Fullscreen API):

enableFullscreen();

(You'll find this function in plugins.js and a working example in tutorials/05_flappyFairy.html)
This launches fullscreen mode as soon as the user clicks or touches the game canvas.
Pressing esc exits fullscreen mode. But you can also assign your own custom keyboard keys to exit fullscreen by optionally listing their ascii key code values in enableFullscreen's arguments, like this :

enableFullscreen(88, 120);

88 is lowercase x, and 120 is uppercase X. Pressing either of these keys will exit fullscreen mode.

The fullscreen API only allows fullscreen mode to be launched directly from user-intiated events attached to HTML elements. Ga only has one HTML element: the canvas. That means enableFullscreen works by checking to see if the canvas has been clicked, and then launching fullscreen mode if it has. And it also means that's not possible to launch fullscreen mode using Ga's button object. So, for example, you can't code something like this:

anyButton.release = function() {
  enableFullscreen();
};

That's because Ga's buttons are just JavaScript objects - not HTML elements.
Obviously, this is not ideal. It would be great to have buttons that launch, exit, and toggle fullscreen mode directly in the game canvas, without needing to overlay any HTML elements to allow this.

But how?
Can anyone suggest some clever solutions?

@kittykatattack
Copy link
Owner Author

I think I found a solution: do a hit test on the button and call enableFullscreen if the pointer is inside the button's area.
That should make a fullscreen toggle button possible too, just using canvas-based buttons.
I will try it and report back! :)

@kittykatattack kittykatattack self-assigned this Mar 31, 2015
@kittykatattack
Copy link
Owner Author

... It doesn't work 😕
It just flags fullscreen mode to activate on the next pointer interaction.
I will look for another solution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant