If you think the Android project TileArena listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package game.tile.arena.util.controller;
/*fromwww.java2s.com*/import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import game.tile.arena.util.Position;
publicclass TouchController extends PlayerController {
TouchController() {
sticks = new Joystick[2];
sticks[MOVEMENT] = new Joystick(
new Position(Gdx.graphics.getWidth()*0.25, Gdx.graphics.getHeight()*0.25),
100, "circle", "joystick_bg");
sticks[ATTACK] = new Joystick(
new Position(Gdx.graphics.getWidth()*0.75, Gdx.graphics.getHeight()*0.25),
100, "circle", "joystick_bg");
}
public Joystick[] sticks;
publicfinalint MOVEMENT = 0;
publicfinalint ATTACK = 1;
public Position getMovement() {
return sticks[MOVEMENT].getStickPosition();
}
public Position getAttack() {
return sticks[ATTACK].getStickPosition();
}
publicvoid render(SpriteBatch batch, double delta) {
sticks[MOVEMENT].renderStick(batch, delta);
sticks[ATTACK].renderStick(batch, delta);
}
}