Updated libgdx to 1.0.1

This commit is contained in:
2014-05-22 17:41:58 -04:30
parent a1891f53d2
commit 653adc91a7
4 changed files with 331 additions and 319 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -40,6 +40,7 @@ import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
@@ -93,6 +94,7 @@ public class CameraCalibrationState extends BaseState{
public CameraCalibrationState(final NxtARCore core){ public CameraCalibrationState(final NxtARCore core){
TextButtonStyle tbs; TextButtonStyle tbs;
FreeTypeFontGenerator generator; FreeTypeFontGenerator generator;
FreeTypeFontParameter param;
this.core = core; this.core = core;
frameMonitor = VideoFrameMonitor.getInstance(); frameMonitor = VideoFrameMonitor.getInstance();
@@ -124,8 +126,12 @@ public class CameraCalibrationState extends BaseState{
// Set up the sampling button. // Set up the sampling button.
// Create the font. // Create the font.
param = new FreeTypeFontParameter();
param.characters = ProjectConstants.FONT_CHARS;
param.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
param.flip = false;
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf")); generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
font = generator.generateFont(ProjectConstants.MENU_BUTTON_FONT_SIZE, ProjectConstants.FONT_CHARS, false); font = generator.generateFont(param);
generator.dispose(); generator.dispose();
// Load the textures. // Load the textures.

View File

@@ -1,318 +1,324 @@
/* /*
* Copyright (C) 2014 Miguel Angel Astor Romero * Copyright (C) 2014 Miguel Angel Astor Romero
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package ve.ucv.ciens.ccg.nxtar.states; package ve.ucv.ciens.ccg.nxtar.states;
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t; import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants; import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap; import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable; import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
public abstract class MainMenuStateBase extends BaseState{
protected static final String TAG = "MAIN_MENU"; public abstract class MainMenuStateBase extends BaseState{
private static final String CLASS_NAME = MainMenuStateBase.class.getSimpleName(); protected static final String TAG = "MAIN_MENU";
private static final String SHADER_PATH = "shaders/bckg/bckg"; private static final String CLASS_NAME = MainMenuStateBase.class.getSimpleName();
private static final String SHADER_PATH = "shaders/bckg/bckg";
protected final int NUM_MENU_BUTTONS = 2;
protected final int NUM_MENU_BUTTONS = 2;
// Helper fields.
protected boolean clientConnected; // Helper fields.
private float u_scaling[]; protected boolean clientConnected;
private float u_scaling[];
// Buttons and other gui components.
protected TextButton startButton; // Buttons and other gui components.
protected Rectangle startButtonBBox; protected TextButton startButton;
protected Sprite clientConnectedLedOn; protected Rectangle startButtonBBox;
protected Sprite clientConnectedLedOff; protected Sprite clientConnectedLedOn;
protected Sprite clientConnectedLedOff;
protected TextButton calibrationButton;
protected Rectangle calibrationButtonBBox; protected TextButton calibrationButton;
protected Sprite cameraCalibratedLedOn; protected Rectangle calibrationButtonBBox;
protected Sprite cameraCalibratedLedOff; protected Sprite cameraCalibratedLedOn;
protected Sprite cameraCalibratedLedOff;
protected Sprite background;
protected Sprite background;
// Graphic data for the start button.
private Texture menuButtonEnabledTexture; // Graphic data for the start button.
private Texture menuButtonDisabledTexture; private Texture menuButtonEnabledTexture;
private Texture menuButtonPressedTexture; private Texture menuButtonDisabledTexture;
private NinePatch menuButtonEnabled9p; private Texture menuButtonPressedTexture;
private NinePatch menuButtonDisabled9p; private NinePatch menuButtonEnabled9p;
private NinePatch menuButtonPressed9p; private NinePatch menuButtonDisabled9p;
private BitmapFont font; private NinePatch menuButtonPressed9p;
private BitmapFont font;
// Other graphics.
private Texture cameraCalibratedLedOffTexture; // Other graphics.
private Texture cameraCalibratedLedOnTexture; private Texture cameraCalibratedLedOffTexture;
private Texture clientConnectedLedOffTexture; private Texture cameraCalibratedLedOnTexture;
private Texture clientConnectedLedOnTexture; private Texture clientConnectedLedOffTexture;
private Texture backgroundTexture; private Texture clientConnectedLedOnTexture;
private ShaderProgram backgroundShader; private Texture backgroundTexture;
private ShaderProgram backgroundShader;
// Button touch helper fields.
protected boolean startButtonTouched; // Button touch helper fields.
protected int startButtonTouchPointer; protected boolean startButtonTouched;
protected boolean calibrationButtonTouched; protected int startButtonTouchPointer;
protected int calibrationButtonTouchPointer; protected boolean calibrationButtonTouched;
protected int calibrationButtonTouchPointer;
public MainMenuStateBase(){
TextureRegion region; public MainMenuStateBase(){
TextButtonStyle tbs; TextureRegion region;
FreeTypeFontGenerator generator; TextButtonStyle tbs;
FreeTypeFontGenerator generator;
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); FreeTypeFontParameter param;
// Create the start button background. this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
menuButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45); // Create the start button background.
menuButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
menuButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png")); menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
menuButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
menuButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png")); menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45);
menuButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
// Create the start button font. menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45);
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
font = generator.generateFont(ProjectConstants.MENU_BUTTON_FONT_SIZE, ProjectConstants.FONT_CHARS, false); // Create the start button font.
generator.dispose(); param = new FreeTypeFontParameter();
param.characters = ProjectConstants.FONT_CHARS;
// Create the start button. param.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
tbs = new TextButtonStyle(); param.flip = false;
tbs.font = font; generator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
tbs.up = new NinePatchDrawable(menuButtonEnabled9p); font = generator.generateFont(param);
tbs.checked = new NinePatchDrawable(menuButtonPressed9p); generator.dispose();
tbs.disabled = new NinePatchDrawable(menuButtonDisabled9p);
tbs.disabledFontColor = new Color(0, 0, 0, 1); // Create the start button.
tbs = new TextButtonStyle();
startButton = new TextButton("Start server", tbs); tbs.font = font;
startButton.setText("Start game"); tbs.up = new NinePatchDrawable(menuButtonEnabled9p);
startButton.setDisabled(true); tbs.checked = new NinePatchDrawable(menuButtonPressed9p);
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight()); tbs.disabled = new NinePatchDrawable(menuButtonDisabled9p);
tbs.disabledFontColor = new Color(0, 0, 0, 1);
// Create the calibration button.
calibrationButton = new TextButton("Calibrate camera", tbs); startButton = new TextButton("Start server", tbs);
calibrationButton.setText("Calibrate camera"); startButton.setText("Start game");
calibrationButton.setDisabled(true); startButton.setDisabled(true);
calibrationButtonBBox = new Rectangle(0, 0, calibrationButton.getWidth(), calibrationButton.getHeight()); startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
// Create the connection leds. // Create the calibration button.
clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png"); calibrationButton = new TextButton("Calibrate camera", tbs);
region = new TextureRegion(clientConnectedLedOnTexture); calibrationButton.setText("Calibrate camera");
clientConnectedLedOn = new Sprite(region); calibrationButton.setDisabled(true);
calibrationButtonBBox = new Rectangle(0, 0, calibrationButton.getWidth(), calibrationButton.getHeight());
clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
region = new TextureRegion(clientConnectedLedOffTexture); // Create the connection leds.
clientConnectedLedOff = new Sprite(region); clientConnectedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
region = new TextureRegion(clientConnectedLedOnTexture);
cameraCalibratedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png"); clientConnectedLedOn = new Sprite(region);
region = new TextureRegion(cameraCalibratedLedOnTexture);
cameraCalibratedLedOn = new Sprite(region); clientConnectedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
region = new TextureRegion(clientConnectedLedOffTexture);
cameraCalibratedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png"); clientConnectedLedOff = new Sprite(region);
region = new TextureRegion(cameraCalibratedLedOffTexture);
cameraCalibratedLedOff = new Sprite(region); cameraCalibratedLedOnTexture = new Texture("data/gfx/gui/Anonymous_Button_Green.png");
region = new TextureRegion(cameraCalibratedLedOnTexture);
// Set up the background. cameraCalibratedLedOn = new Sprite(region);
backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png"));
backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); cameraCalibratedLedOffTexture = new Texture("data/gfx/gui/Anonymous_Button_Red.png");
backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); region = new TextureRegion(cameraCalibratedLedOffTexture);
region = new TextureRegion(backgroundTexture); cameraCalibratedLedOff = new Sprite(region);
background = new Sprite(backgroundTexture);
background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Set up the background.
background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2)); backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png"));
backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl")); backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
if(!backgroundShader.isCompiled()){ region = new TextureRegion(backgroundTexture);
Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader."); background = new Sprite(backgroundTexture);
Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog()); background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
backgroundShader = null; background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2));
}
backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl"));
u_scaling = new float[2]; if(!backgroundShader.isCompiled()){
u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f; Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader.");
u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f; Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog());
backgroundShader = null;
}
win2world = new Vector3(0.0f, 0.0f, 0.0f);
touchPointWorldCoords = new Vector2(); u_scaling = new float[2];
startButtonTouched = false; u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
startButtonTouchPointer = -1; u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
calibrationButtonTouched = false;
calibrationButtonTouchPointer = -1;
win2world = new Vector3(0.0f, 0.0f, 0.0f);
clientConnected = false; touchPointWorldCoords = new Vector2();
stateActive = false; startButtonTouched = false;
} startButtonTouchPointer = -1;
calibrationButtonTouched = false;
@Override calibrationButtonTouchPointer = -1;
public abstract void render(float delta);
clientConnected = false;
@Override stateActive = false;
public void resize(int width, int height){ } }
@Override @Override
public void show(){ } public abstract void render(float delta);
@Override
public void hide(){ } @Override
public void resize(int width, int height){ }
@Override
public void pause(){ } @Override
public void show(){ }
@Override @Override
public void resume(){ } public void hide(){ }
@Override @Override
public void dispose(){ public void pause(){ }
menuButtonEnabledTexture.dispose();
menuButtonDisabledTexture.dispose(); @Override
menuButtonPressedTexture.dispose(); public void resume(){ }
clientConnectedLedOnTexture.dispose();
clientConnectedLedOffTexture.dispose(); @Override
cameraCalibratedLedOnTexture.dispose(); public void dispose(){
cameraCalibratedLedOffTexture.dispose(); menuButtonEnabledTexture.dispose();
backgroundTexture.dispose(); menuButtonDisabledTexture.dispose();
if(backgroundShader != null) backgroundShader.dispose(); menuButtonPressedTexture.dispose();
font.dispose(); clientConnectedLedOnTexture.dispose();
} clientConnectedLedOffTexture.dispose();
cameraCalibratedLedOnTexture.dispose();
protected void drawBackground(SpriteBatch batch){ cameraCalibratedLedOffTexture.dispose();
if(backgroundShader != null){ backgroundTexture.dispose();
batch.setShader(backgroundShader); if(backgroundShader != null) backgroundShader.dispose();
backgroundShader.setUniform2fv("u_scaling", u_scaling, 0, 2); font.dispose();
} }
background.draw(batch);
if(backgroundShader != null) batch.setShader(null); protected void drawBackground(SpriteBatch batch){
} if(backgroundShader != null){
batch.setShader(backgroundShader);
@Override backgroundShader.setUniform2fv("u_scaling", u_scaling, 0, 2);
public void onStateSet(){ }
stateActive = true; background.draw(batch);
Gdx.input.setInputProcessor(this); if(backgroundShader != null) batch.setShader(null);
Gdx.input.setCatchBackKey(true); }
Gdx.input.setCatchMenuKey(true);
} @Override
public void onStateSet(){
@Override stateActive = true;
public void onStateUnset(){ Gdx.input.setInputProcessor(this);
stateActive = false; Gdx.input.setCatchBackKey(true);
Gdx.input.setInputProcessor(null); Gdx.input.setCatchMenuKey(true);
Gdx.input.setCatchBackKey(false); }
Gdx.input.setCatchMenuKey(false);
} @Override
public void onStateUnset(){
public void onClientConnected(){ stateActive = false;
clientConnected = true; Gdx.input.setInputProcessor(null);
startButton.setDisabled(false); Gdx.input.setCatchBackKey(false);
calibrationButton.setDisabled(false); Gdx.input.setCatchMenuKey(false);
} }
/*;;;;;;;;;;;;;;;;;;;;;;;;;; public void onClientConnected(){
; INPUT LISTENER METHODS ; clientConnected = true;
;;;;;;;;;;;;;;;;;;;;;;;;;;*/ startButton.setDisabled(false);
calibrationButton.setDisabled(false);
@Override }
public boolean touchDown(int screenX, int screenY, int pointer, int button){
unprojectTouch(screenX, screenY); /*;;;;;;;;;;;;;;;;;;;;;;;;;;
; INPUT LISTENER METHODS ;
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button)); ;;;;;;;;;;;;;;;;;;;;;;;;;;*/
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
@Override
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && !calibrationButtonTouched){ public boolean touchDown(int screenX, int screenY, int pointer, int button){
startButton.setChecked(true); unprojectTouch(screenX, screenY);
startButtonTouched = true;
startButtonTouchPointer = pointer; Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed."); Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
}else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && !startButtonTouched){
calibrationButton.setChecked(true); if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && !calibrationButtonTouched){
calibrationButtonTouched = true; startButton.setChecked(true);
calibrationButtonTouchPointer = pointer; startButtonTouched = true;
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button pressed."); startButtonTouchPointer = pointer;
} Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
}else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && !startButtonTouched){
return true; calibrationButton.setChecked(true);
} calibrationButtonTouched = true;
calibrationButtonTouchPointer = pointer;
@Override Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button pressed.");
public boolean touchUp(int screenX, int screenY, int pointer, int button){ }
unprojectTouch(screenX, screenY);
return true;
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button)); }
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
@Override
if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && startButtonTouched){ public boolean touchUp(int screenX, int screenY, int pointer, int button){
startButton.setChecked(false); unprojectTouch(screenX, screenY);
startButtonTouched = false;
startButtonTouchPointer = -1; Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
core.nextState = game_states_t.IN_GAME; Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
}else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && calibrationButtonTouched){ if(!startButton.isDisabled() && startButtonBBox.contains(touchPointWorldCoords) && startButtonTouched){
calibrationButton.setChecked(false); startButton.setChecked(false);
calibrationButtonTouched = false; startButtonTouched = false;
calibrationButtonTouchPointer = -1; startButtonTouchPointer = -1;
core.nextState = game_states_t.CALIBRATION; core.nextState = game_states_t.IN_GAME;
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button released."); Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
} }else if(!calibrationButton.isDisabled() && calibrationButtonBBox.contains(touchPointWorldCoords) && calibrationButtonTouched){
calibrationButton.setChecked(false);
return true; calibrationButtonTouched = false;
} calibrationButtonTouchPointer = -1;
core.nextState = game_states_t.CALIBRATION;
@Override Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Calibration button released.");
public boolean touchDragged(int screenX, int screenY, int pointer){ }
unprojectTouch(screenX, screenY);
return true;
if(!startButton.isDisabled() && startButtonTouched && pointer == startButtonTouchPointer && !startButtonBBox.contains(touchPointWorldCoords)){ }
startButtonTouchPointer = -1;
startButtonTouched = false; @Override
startButton.setChecked(false); public boolean touchDragged(int screenX, int screenY, int pointer){
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released."); unprojectTouch(screenX, screenY);
}else if(!calibrationButton.isDisabled() && calibrationButtonTouched && pointer == calibrationButtonTouchPointer && !calibrationButtonBBox.contains(touchPointWorldCoords)){
calibrationButtonTouchPointer = -1; if(!startButton.isDisabled() && startButtonTouched && pointer == startButtonTouchPointer && !startButtonBBox.contains(touchPointWorldCoords)){
calibrationButtonTouched = false; startButtonTouchPointer = -1;
calibrationButton.setChecked(false); startButtonTouched = false;
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released."); startButton.setChecked(false);
} Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
}else if(!calibrationButton.isDisabled() && calibrationButtonTouched && pointer == calibrationButtonTouchPointer && !calibrationButtonBBox.contains(touchPointWorldCoords)){
return true; calibrationButtonTouchPointer = -1;
} calibrationButtonTouched = false;
calibrationButton.setChecked(false);
@Override Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
public boolean keyDown(int keycode){ }
if(keycode == Input.Keys.BACK){
// Ignore. return true;
return true; }
}
return false; @Override
} public boolean keyDown(int keycode){
} if(keycode == Input.Keys.BACK){
// Ignore.
return true;
}
return false;
}
}