21 lines
497 B
JavaScript
21 lines
497 B
JavaScript
import { GAME_WIDTH } from '../config.js';
|
|
import { Button } from './Button.js';
|
|
|
|
export function addFullscreenButton(scene) {
|
|
const width = 300;
|
|
return new Button(
|
|
scene,
|
|
GAME_WIDTH - width / 2 - 30,
|
|
52,
|
|
'Toggle Fullscreen',
|
|
() => {
|
|
if (document.fullscreenElement) {
|
|
document.exitFullscreen();
|
|
} else {
|
|
document.documentElement.requestFullscreen();
|
|
}
|
|
},
|
|
{ width, height: 52, fontSize: 22, variant: 'ghost' },
|
|
).setDepth(100);
|
|
}
|