[Buildbox like a boss] Running Buildbox Android game in fullscreen mode
When you export an android game from buildbox, and build it, it’ll not run in fullscreen “immersive mode” by default.
immersive mode allow you to hide android softkeys, and use the precious gained space to show more stuff of your game or to place a banner.
here is a quick tip to make a buildbox game run in fullscreen mode.
1 – Find and edit PTPlayer.java file.
this file is placed un a sub-directory under android/src/ folder.
it correspond to the package path you specified while configuring your buildbox package for android
considering that you used com.mycompany.mygame as a package name, you’ll find PTPlayer.java under android/src/com/mycompany/mygame/PTPlayer.java
2 – Prepare the code
Find this line of code in the beggining of PTPlayer.java
1 |
private static native void loadModelController(); |
and add after
1 2 |
private static native void loadModelController(); private Cocos2dxGLSurfaceView glSurfaceView; //Add this line |
Replace the content of the function “onCreateView” with the following
1 2 3 4 5 6 7 |
@Override public Cocos2dxGLSurfaceView onCreateView() { glSurfaceView = new Cocos2dxGLSurfaceView(this); glSurfaceView.setEGLConfigChooser(8, 8, 8, 0, 0, 0); setFullscreen(); return glSurfaceView; } |
3 – Add fullscreen methods
At the end of PTPlayer.java file, before the latest closing bracket “}” add the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { this.setFullscreen(); } } private void setFullscreen() { glSurfaceView.setSystemUiVisibility( Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_STABLE | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_HIDE_NAVIGATION | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_FULLSCREEN | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } |
Now rebuild your game and install it, it’s running in fullscreen mode !
Note.
Each time you’ll export the game from buildbox your modifications to PTPlayer.java will be lost.
one easy solution is to keep a modified copy of the file in a safe place, and replace the generated buildbox version after each export.