File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ class RaylibJs {
6060 return ;
6161 }
6262
63- const canvas = document . getElementById ( canvasId ) ;
63+ let canvas = document . getElementById ( canvasId ) ;
6464 this . ctx = canvas . getContext ( "2d" ) ;
6565 if ( this . ctx === null ) {
6666 throw new Error ( "Could not create 2d canvas context" ) ;
@@ -117,6 +117,18 @@ class RaylibJs {
117117 return false ;
118118 }
119119
120+ IsWindowFullscreen ( ) {
121+ return document . fullscreenElement && document . fullscreenElement === this . ctx . canvas ;
122+ }
123+
124+ ToggleFullscreen ( ) {
125+ if ( this . IsWindowFullscreen ( ) ) {
126+ document . exitFullscreen ( )
127+ } else {
128+ this . ctx . canvas . requestFullscreen ( ) ;
129+ }
130+ }
131+
120132 SetTargetFPS ( fps ) {
121133 console . log ( `The game wants to run at ${ fps } FPS, but in Web we gonna just ignore it.` ) ;
122134 this . targetFPS = fps ;
You can’t perform that action at this time.
0 commit comments