So here is my problem, Im not sure whats the deal here but its supposed to be pretty straightforward. I have a texture that i want to draw either on the left half of the screen or the right half of the screen. When the corresponding side of the screen is touched
METHOD THAT CALLS THE METHOD:
public void screenTouched() {
if (Gdx.input.justTouched()) {
main_char.updateMainCharacter(Gdx.input.getX(), main_char.getPosition().y);
}
METHOD THAT MOVES THE TEXTURE:
public void updateMainCharacter(float touch_pos_x, float pos_y) {
//main_char is already on left side
if (position.x < ClimberDude.V_WIDTH / 2 && touch_pos_x < ClimberDude.V_WIDTH / 2) {
position.x = 0;
position.y = pos_y + main_char.getHeight();
}
//main_char is already on right side
else if (position.x > ClimberDude.V_WIDTH / 2 && touch_pos_x > ClimberDude.V_WIDTH / 2) {
position.x = ClimberDude.V_WIDTH - main_char.getWidth();
position.y = pos_y + main_char.getHeight();
}
else if (touch_pos_x < ClimberDude.V_WIDTH / 2) {
position.x = 0;
position.y = pos_y;
}
else if (touch_pos_x > ClimberDude.V_WIDTH / 2) {
position.x = ClimberDude.V_WIDTH - main_char.getWidth();
position.y = pos_y;
}
}