org.newdawn.slick.state
Class BasicGameState

java.lang.Object
  extended by org.newdawn.slick.state.BasicGameState
All Implemented Interfaces:
ControlledInputReciever, ControllerListener, InputListener, KeyListener, MouseListener, GameState
Direct Known Subclasses:
TestState1, TestState2, TestState3

public abstract class BasicGameState
extends java.lang.Object
implements GameState

A simple state used an adapter so we don't have to implement all the event methods every time.

Author:
kevin

Constructor Summary
BasicGameState()
           
 
Method Summary
 void controllerButtonPressed(int controller, int button)
          Notification that a button control has been pressed on the controller.
 void controllerButtonReleased(int controller, int button)
          Notification that a button control has been released on the controller.
 void controllerDownPressed(int controller)
          Notification that the down control has been pressed on the controller.
 void controllerDownReleased(int controller)
          Notification that the down control has been released on the controller.
 void controllerLeftPressed(int controller)
          Notification that the left control has been pressed on the controller.
 void controllerLeftReleased(int controller)
          Notification that the left control has been released on the controller.
 void controllerRightPressed(int controller)
          Notification that the right control has been pressed on the controller.
 void controllerRightReleased(int controller)
          Notification that the right control has been released on the controller.
 void controllerUpPressed(int controller)
          Notification that the up control has been pressed on the controller.
 void controllerUpReleased(int controller)
          Notification that the up control has been released on the controller.
 void enter(GameContainer container, StateBasedGame game)
          Notification that we've entered this game state
abstract  int getID()
          Get the ID of this state
 void inputEnded()
          Notification that all input events have been sent for this frame
 void inputStarted()
          Notification that input is about to be processed
 boolean isAcceptingInput()
          Check if this input listener is accepting input
 void keyPressed(int key, char c)
          Notification that a key was pressed
 void keyReleased(int key, char c)
          Notification that a key was released
 void leave(GameContainer container, StateBasedGame game)
          Notification that we're leaving this game state
 void mouseClicked(int button, int x, int y, int clickCount)
          Notification that a mouse button was clicked.
 void mouseDragged(int oldx, int oldy, int newx, int newy)
          Notification that mouse cursor was dragged
 void mouseMoved(int oldx, int oldy, int newx, int newy)
          Notification that mouse cursor was moved
 void mousePressed(int button, int x, int y)
          Notification that a mouse button was pressed
 void mouseReleased(int button, int x, int y)
          Notification that a mouse button was released
 void mouseWheelMoved(int newValue)
          Notification that the mouse wheel position was updated
 void setInput(Input input)
          Set the input that events are being sent from
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.newdawn.slick.state.GameState
init, render, update
 

Constructor Detail

BasicGameState

public BasicGameState()
Method Detail

inputStarted

public void inputStarted()
Description copied from interface: ControlledInputReciever
Notification that input is about to be processed

Specified by:
inputStarted in interface ControlledInputReciever
See Also:
ControlledInputReciever.inputStarted()

isAcceptingInput

public boolean isAcceptingInput()
Description copied from interface: ControlledInputReciever
Check if this input listener is accepting input

Specified by:
isAcceptingInput in interface ControlledInputReciever
Returns:
True if the input listener should recieve events
See Also:
ControlledInputReciever.isAcceptingInput()

setInput

public void setInput(Input input)
Description copied from interface: ControlledInputReciever
Set the input that events are being sent from

Specified by:
setInput in interface ControlledInputReciever
Parameters:
input - The input instance sending events
See Also:
ControlledInputReciever.setInput(org.newdawn.slick.Input)

inputEnded

public void inputEnded()
Description copied from interface: ControlledInputReciever
Notification that all input events have been sent for this frame

Specified by:
inputEnded in interface ControlledInputReciever
See Also:
ControlledInputReciever.inputEnded()

getID

public abstract int getID()
Description copied from interface: GameState
Get the ID of this state

Specified by:
getID in interface GameState
Returns:
The game unique ID of this state
See Also:
GameState.getID()

controllerButtonPressed

public void controllerButtonPressed(int controller,
                                    int button)
Description copied from interface: ControllerListener
Notification that a button control has been pressed on the controller.

Specified by:
controllerButtonPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
button - The index of the button pressed (starting at 1)
See Also:
ControllerListener.controllerButtonPressed(int, int)

controllerButtonReleased

public void controllerButtonReleased(int controller,
                                     int button)
Description copied from interface: ControllerListener
Notification that a button control has been released on the controller.

Specified by:
controllerButtonReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
button - The index of the button released (starting at 1)
See Also:
ControllerListener.controllerButtonReleased(int, int)

controllerDownPressed

public void controllerDownPressed(int controller)
Description copied from interface: ControllerListener
Notification that the down control has been pressed on the controller.

Specified by:
controllerDownPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerDownPressed(int)

controllerDownReleased

public void controllerDownReleased(int controller)
Description copied from interface: ControllerListener
Notification that the down control has been released on the controller.

Specified by:
controllerDownReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerDownReleased(int)

controllerLeftPressed

public void controllerLeftPressed(int controller)
Description copied from interface: ControllerListener
Notification that the left control has been pressed on the controller.

Specified by:
controllerLeftPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerLeftPressed(int)

controllerLeftReleased

public void controllerLeftReleased(int controller)
Description copied from interface: ControllerListener
Notification that the left control has been released on the controller.

Specified by:
controllerLeftReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerLeftReleased(int)

controllerRightPressed

public void controllerRightPressed(int controller)
Description copied from interface: ControllerListener
Notification that the right control has been pressed on the controller.

Specified by:
controllerRightPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerRightPressed(int)

controllerRightReleased

public void controllerRightReleased(int controller)
Description copied from interface: ControllerListener
Notification that the right control has been released on the controller.

Specified by:
controllerRightReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerRightReleased(int)

controllerUpPressed

public void controllerUpPressed(int controller)
Description copied from interface: ControllerListener
Notification that the up control has been pressed on the controller.

Specified by:
controllerUpPressed in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was pressed.
See Also:
ControllerListener.controllerUpPressed(int)

controllerUpReleased

public void controllerUpReleased(int controller)
Description copied from interface: ControllerListener
Notification that the up control has been released on the controller.

Specified by:
controllerUpReleased in interface ControllerListener
Parameters:
controller - The index of the controller on which the control was released.
See Also:
ControllerListener.controllerUpReleased(int)

keyPressed

public void keyPressed(int key,
                       char c)
Description copied from interface: KeyListener
Notification that a key was pressed

Specified by:
keyPressed in interface KeyListener
Parameters:
key - The key code that was pressed (@see org.newdawn.slick.Input)
c - The character of the key that was pressed
See Also:
KeyListener.keyPressed(int, char)

keyReleased

public void keyReleased(int key,
                        char c)
Description copied from interface: KeyListener
Notification that a key was released

Specified by:
keyReleased in interface KeyListener
Parameters:
key - The key code that was released (@see org.newdawn.slick.Input)
c - The character of the key that was released
See Also:
KeyListener.keyReleased(int, char)

mouseMoved

public void mouseMoved(int oldx,
                       int oldy,
                       int newx,
                       int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was moved

Specified by:
mouseMoved in interface MouseListener
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
MouseListener.mouseMoved(int, int, int, int)

mouseDragged

public void mouseDragged(int oldx,
                         int oldy,
                         int newx,
                         int newy)
Description copied from interface: MouseListener
Notification that mouse cursor was dragged

Specified by:
mouseDragged in interface MouseListener
Parameters:
oldx - The old x position of the mouse
oldy - The old y position of the mouse
newx - The new x position of the mouse
newy - The new y position of the mouse
See Also:
MouseListener.mouseDragged(int, int, int, int)

mouseClicked

public void mouseClicked(int button,
                         int x,
                         int y,
                         int clickCount)
Description copied from interface: MouseListener
Notification that a mouse button was clicked. Due to double click handling the single click may be delayed slightly. For absolute notification of single clicks use mousePressed(). To be absolute this method should only be used when considering double clicks

Specified by:
mouseClicked in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was pressed
y - The y position of the mouse when the button was pressed
clickCount - The number of times the button was clicked
See Also:
MouseListener.mouseClicked(int, int, int, int)

mousePressed

public void mousePressed(int button,
                         int x,
                         int y)
Description copied from interface: MouseListener
Notification that a mouse button was pressed

Specified by:
mousePressed in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was pressed
y - The y position of the mouse when the button was pressed
See Also:
MouseListener.mousePressed(int, int, int)

mouseReleased

public void mouseReleased(int button,
                          int x,
                          int y)
Description copied from interface: MouseListener
Notification that a mouse button was released

Specified by:
mouseReleased in interface MouseListener
Parameters:
button - The index of the button (starting at 0)
x - The x position of the mouse when the button was released
y - The y position of the mouse when the button was released
See Also:
MouseListener.mouseReleased(int, int, int)

enter

public void enter(GameContainer container,
                  StateBasedGame game)
           throws SlickException
Description copied from interface: GameState
Notification that we've entered this game state

Specified by:
enter in interface GameState
Parameters:
container - The container holding the game
game - The game holding this state
Throws:
SlickException - Indicates an internal error that will be reported through the standard framework mechanism
See Also:
GameState.enter(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame)

leave

public void leave(GameContainer container,
                  StateBasedGame game)
           throws SlickException
Description copied from interface: GameState
Notification that we're leaving this game state

Specified by:
leave in interface GameState
Parameters:
container - The container holding the game
game - The game holding this state
Throws:
SlickException - Indicates an internal error that will be reported through the standard framework mechanism
See Also:
GameState.leave(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame)

mouseWheelMoved

public void mouseWheelMoved(int newValue)
Description copied from interface: MouseListener
Notification that the mouse wheel position was updated

Specified by:
mouseWheelMoved in interface MouseListener
Parameters:
newValue - The amount of the wheel has moved
See Also:
MouseListener.mouseWheelMoved(int)


Copyright © 2006 New Dawn Software. All Rights Reserved.