Skip to content

Commit

Permalink
Automatically enable joystick when game launched for web platform whe…
Browse files Browse the repository at this point in the history
…n device has touch screen.
  • Loading branch information
lanceewing committed Mar 24, 2024
1 parent b9ffd0b commit 5a22f68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/java/com/agifans/agile/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public void show() {
Gdx.input.setInputProcessor(landscapeInputProcessor);
}

if (agileRunner.hasTouchScreen() && !Gdx.graphics.isFullscreen()) {
gameScreenInputProcessor.switchIntoFullScreen();
if (agileRunner.hasTouchScreen()) {
gameScreenInputProcessor.setJoystickAlignment(JoystickAlignment.RIGHT);

if (!Gdx.graphics.isFullscreen()) {
gameScreenInputProcessor.switchIntoFullScreen();
}
}

agileRunner.start(appConfigItem.getFilePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ public JoystickAlignment getJoystickAlignment() {
return joystickAlignment;
}

/**
* Sets the current joystick screen alignment, i.e. where to place it on the
* screen (left aligned, middle aligned, right aligned, or turned off)
*
* @param joystickAlignment
*/
public void setJoystickAlignment(JoystickAlignment joystickAlignment) {
this.joystickAlignment = joystickAlignment;
}

public static enum JoystickAlignment {
OFF, RIGHT, MIDDLE, LEFT;

Expand Down

0 comments on commit 5a22f68

Please sign in to comment.