Sends a request to the browser to ask it to go in to full screen mode, using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API}.
If the browser does not support this, a FULLSCREEN_UNSUPPORTED
event will be emitted.
This method must be called from a pointerup
user-input gesture (not pointerdown
). You cannot launch
games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked
from fullscreen unless the iframe has the allowfullscreen
attribute.
On touch devices, such as Android and iOS Safari, you should always use pointerup
and NOT pointerdown
,
otherwise the request will fail unless the document in which your game is embedded has already received
some form of touch input, which you cannot guarantee. Activating fullscreen via pointerup
circumvents
this issue.
Performing an action that navigates to another page, or opens another tab, will automatically cancel
fullscreen mode, as will the user pressing the ESC key. To cancel fullscreen mode directly from your game,
i.e. by clicking an icon, call the stopFullscreen
method.
A browser can only send one DOM element into fullscreen. You can control which element this is by
setting the fullscreenTarget
property in your game config, or changing the property in the Scale Manager.
Note that the game canvas must be a child of the target. If you do not give a target, Phaser will
automatically create a blank <div>
element and move the canvas into it, before going fullscreen.
When it leaves fullscreen, the div will be removed.
name | type | arguments | description |
---|---|---|---|
fullscreenOptions | object | <optional> |
The FullscreenOptions dictionary is used to provide configuration options when entering full screen. |