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 {
60
60
return ;
61
61
}
62
62
63
- const canvas = document . getElementById ( canvasId ) ;
63
+ let canvas = document . getElementById ( canvasId ) ;
64
64
this . ctx = canvas . getContext ( "2d" ) ;
65
65
if ( this . ctx === null ) {
66
66
throw new Error ( "Could not create 2d canvas context" ) ;
@@ -117,6 +117,18 @@ class RaylibJs {
117
117
return false ;
118
118
}
119
119
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
+
120
132
SetTargetFPS ( fps ) {
121
133
console . log ( `The game wants to run at ${ fps } FPS, but in Web we gonna just ignore it.` ) ;
122
134
this . targetFPS = fps ;
You can’t perform that action at this time.
0 commit comments