Game control interface for Android phone/tablet games

Hi,

First post on JGO.
I’m a beginning java/android programmer & currently working together with my brother & another friend on a 2D vertical scolling shooter as well as a 2D platform games based on 2 old Konami MSX games (Knightmare & The Goonies).

sWrWxdr0SIs

We’re coding & testing our games in Eclipse and currently using the keyboard input to move our heros around and to shoot or punch.

I’m thinking about how we should incorporate a game controller in the future that enables the game to be played on a tablet or phone.(like a virutal on screen controller or moving our tablet/phone combined with tapping or whatelse is there…)

Thought I put out a post here.
Maybe you could give me some good ideas for how to create one.
Links, resources, code, tutorials.

ytoPfZyMNeM

I can’t offer any resources or advice on how to actually create this, however; if I were designing the game, I would probably either:

  1. use a left/right tilt system to move the character back and forth and tap to shoot.
  2. have a digital joystick and a fire button to move the player around

I would assume that android APIs have the tilting somewhat built-in, and the joystick you’ll just have to do a little bit of trig to get it right.

Hope this helps you get started :slight_smile:

Are you using any framework or have you built your own?

I’m using LibGDX as my main library…

You can either implement “Input”, or you can access it directly like I do. This is how I get input from a button that I have drawn to the screen…

if (Gdx.input.isTouched()){
	  	if (Gdx.input.getX() > 800 && Gdx.input.getX() < 870 && Gdx.input.getY() > 34 && Gdx.input.getY() < 104) { //This is true if the screen is touched between 800x-870x and between 34y-104y
	  			//Do an action or something
	  	}
}

However, you’ll want to set it up so that the coordinates work on all phones. Let me know if you want to know how.

In libGDX there is also a UI Widget called a TouchPad. It acts like a Joystick.