android.gameengine.icadroids.input
Class OnScreenButtons

java.lang.Object
  extended by android.gameengine.icadroids.input.OnScreenButtons

public class OnScreenButtons
extends java.lang.Object

This class provides statics and a few function to easily make use of the touch functionality of an android device. This class manages and draws virtual buttons to the screen to detect for input. When a button is enabled (by default) the user can check wether a button is pressed or not, by accessing the static boolean values for each correspodending button. Do not make an instance of this class yourself. If you want to use the OnScreenButtons in your game, set the static variable use to true.

Author:
Roel & Bas

Field Summary
static boolean buttonA
          holds the values of wether or not the button has been pressed.
static boolean buttonB
          holds the values of wether or not the button has been pressed.
static boolean buttonX
          holds the values of wether or not the button has been pressed.
static boolean buttonY
          holds the values of wether or not the button has been pressed.
static boolean dPadDown
          holds the values of wether or not the button has been pressed.
static boolean dPadLeft
          holds the values of wether or not the button has been pressed.
static boolean dPadRight
          holds the values of wether or not the button has been pressed.
static boolean dPadUp
          holds the values of wether or not the button has been pressed.
static boolean feedback
          feedback: wether or not to allow feedback
static int opacity
          opacity: sets the opacity of all the buttons in a range from 0 to 255
static boolean select
          holds the values of wether or not the button has been pressed.
static boolean start
          holds the values of wether or not the button has been pressed.
static boolean use
          use : wether or not to actually use these buttons
 
Constructor Summary
OnScreenButtons(Activity gameEngine)
          Do not call the constructor yourself this is for the GameEngine.
 
Method Summary
protected static void buttonPressed(int buttonId)
          Method that will be called by the OnScreenButton to notify the onscreenbuttons an button has been pressed
protected static void buttonReleased(int buttonId)
          Method that will be called by the OnScreenButton to notify the onscreenbuttons an button has been pressed
static void disableButton(int buttonId)
          Disable a onscreenbutton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

use

public static boolean use
use : wether or not to actually use these buttons


feedback

public static boolean feedback
feedback: wether or not to allow feedback


opacity

public static int opacity
opacity: sets the opacity of all the buttons in a range from 0 to 255


dPadUp

public static boolean dPadUp
holds the values of wether or not the button has been pressed. Use these to check for input.


dPadDown

public static boolean dPadDown
holds the values of wether or not the button has been pressed. Use these to check for input.


dPadLeft

public static boolean dPadLeft
holds the values of wether or not the button has been pressed. Use these to check for input.


dPadRight

public static boolean dPadRight
holds the values of wether or not the button has been pressed. Use these to check for input.


buttonA

public static boolean buttonA
holds the values of wether or not the button has been pressed. Use these to check for input.


buttonB

public static boolean buttonB
holds the values of wether or not the button has been pressed. Use these to check for input.


buttonX

public static boolean buttonX
holds the values of wether or not the button has been pressed. Use these to check for input.


buttonY

public static boolean buttonY
holds the values of wether or not the button has been pressed. Use these to check for input.


start

public static boolean start
holds the values of wether or not the button has been pressed. Use these to check for input.


select

public static boolean select
holds the values of wether or not the button has been pressed. Use these to check for input.

Constructor Detail

OnScreenButtons

public OnScreenButtons(Activity gameEngine)
Do not call the constructor yourself this is for the GameEngine. The constructor will load the onScreenButtons.xml view and places it on top of the canvas.

Parameters:
gameEngine - : The context is required by this class so it can receive the screen width and height.
Method Detail

buttonPressed

protected static void buttonPressed(int buttonId)
Method that will be called by the OnScreenButton to notify the onscreenbuttons an button has been pressed

Parameters:
buttonId - The layout id of the button

buttonReleased

protected static void buttonReleased(int buttonId)
Method that will be called by the OnScreenButton to notify the onscreenbuttons an button has been pressed

Parameters:
buttonId -

disableButton

public static void disableButton(int buttonId)
Disable a onscreenbutton

Parameters:
buttonId - The id of the button that needs to be dissabled. you can get the button id by using R.id.(button name).
For example: disableButton(R.id.dpadCenter);
You also have:

buttonA, buttonB, buttonX, buttonY, dpadUp, dpadDown, dpadLeft, dpadRight, buttonSelect and buttonStart