Skip to content

Commit

Permalink
Centered the joystick touchpad between keyboard and AGI Screen for po…
Browse files Browse the repository at this point in the history
…rtrait mode.
  • Loading branch information
lanceewing committed Mar 17, 2024
1 parent 953bb50 commit 55f32c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions core/src/main/java/com/agifans/agile/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,19 @@ private void draw(float delta) {
false, false);
batch.end();

// Render the UI elements, e.g. the keyboard and joystick icons.
// Now render the UI elements, e.g. the keyboard, full screen, and joystick icons.
viewportManager.getCurrentCamera().update();
batch.setProjectionMatrix(viewportManager.getCurrentCamera().combined);
batch.enableBlending();
batch.begin();

// The keyboard is always render in portrait mode, as there is space for it,
// but in landscape mode, it needs to be enabled via the keyboard icon.
if (keyboardType.isRendered() || viewportManager.isPortrait()) {
batch.setColor(c.r, c.g, c.b, keyboardType.getOpacity());
batch.draw(keyboardType.getTexture(), 0, keyboardType.getRenderOffset());
}

// The keyboard and joystick icons are rendered only when an input type isn't
// showing.
batch.setColor(c.r, c.g, c.b, 0.5f);
if (viewportManager.isPortrait()) {
batch.draw(joystickIcon, 0, 0);
Expand All @@ -301,11 +301,15 @@ private void draw(float delta) {

batch.end();

// The joystick touch pad is updated and rendered via the Stage.
if (gameScreenInputProcessor.isJoystickActive()) {
float joyX = 0;
float joyY = 0;
if (viewportManager.isPortrait()) {
portraitTouchpad.setY(viewportManager.getHeight() - 1050);
// Top of keyboard is: 765 + 145 = 910. Touchpad is 200 high.
int agiScreenBase = (int)(viewportManager.getHeight() - (viewportManager.getWidth() / 1.32));
int midBetweenKeybAndPic = ((agiScreenBase + 910) / 2);
portraitTouchpad.setY(midBetweenKeybAndPic - 100);
portraitTouchpadStage.act(delta);
portraitTouchpadStage.draw();
joyX = portraitTouchpad.getKnobPercentX();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.agifans.agile.GameScreen;
import com.agifans.agile.UserInput;
import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.Input.Keys;
Expand Down Expand Up @@ -118,7 +117,7 @@ public GameScreenInputProcessor(GameScreen gameScreen, DialogHandler dialogHandl
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
// Convert the screen coordinates to world coordinates.
Vector2 touchXY = viewportManager.unproject(screenX, screenY);

// Update AGI mouse variables.
updateAGIMouse(touchXY, button, true);

Expand Down

0 comments on commit 55f32c4

Please sign in to comment.