|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Canvas
framework.Game
public abstract class Game
Base class that all games should extend.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Canvas |
|---|
Canvas.AccessibleAWTCanvas |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
Game()
Constructs a new game. |
|
Game(int width,
int height)
Constructs a new game with specified virtual size. |
|
| Method Summary | |
|---|---|
void |
addGameEndListener(GameEndListener listener)
Adds the specified game end listener to receive game end events from this Game. |
void |
addNotify()
Overridden to start the game thread when added to a container. |
void |
dispose()
Called just after the game loop ends. |
abstract void |
draw(Graphics2D g)
Update the graphical display. |
protected void |
drawImpl()
Sets up the graphics context and calls draw(Graphics2D). |
int |
getActingHeight()
Get the height that the component thinks it is for the purposes of drawing. |
Dimension |
getActingSize()
Get the size that the component thinks it is for the purposes of drawing. |
int |
getActingWidth()
Get the width that the component thinks it is for the purposes of drawing. |
protected Graphics2D |
getBufferGraphics()
Get a Graphics2D object that can be used to draw to the buffer. |
Dimension |
getPreferredSize()
Overridden to return the virtual size if it is set. |
void |
init()
Called just before the game loop is started. |
boolean |
isRunning()
|
void |
processEndEvent(GameEndEvent e)
Processes game end events by dispatching them to any registered GameEndListener objects. |
void |
processMouseEvent(MouseEvent e)
Overridden to fix the mouse position if necessary. |
void |
processMouseMotionEvent(MouseEvent e)
Overridden to fix the mouse position if necessary. |
void |
processMouseWheelEvent(MouseWheelEvent e)
Overridden to fix the mouse position if necessary. |
void |
removeGameEndListener(GameEndListener listener)
Removes the specified game end listener so that it no longer receives game end events from this Game. |
void |
removeNotify()
Overridden to stop the game thread when removed from a container. |
void |
run()
This method runs on the game thread and controls the game loop. |
void |
setActingSize(int width,
int height)
Sets the size that this component will pretend to be. |
void |
setVirtualSize(int width,
int height)
Deprecated. |
protected void |
showBuffer()
Makes the contents of the buffer visible. |
abstract void |
update(int time)
Update the game state. |
| Methods inherited from class java.awt.Canvas |
|---|
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Game()
public Game(int width,
int height)
| Method Detail |
|---|
public abstract void update(int time)
public abstract void draw(Graphics2D g)
public void init()
public void dispose()
public boolean isRunning()
public void run()
run in interface Runnableprotected void drawImpl()
draw(Graphics2D).
You can ignore this unless you want to override run().
protected Graphics2D getBufferGraphics()
Graphics2D object that can be used to draw to the buffer.
You can ignore this unless you want to override drawImpl().
protected void showBuffer()
drawImpl().
public void processMouseEvent(MouseEvent e)
processMouseEvent in class Componentpublic void processMouseMotionEvent(MouseEvent e)
processMouseMotionEvent in class Componentpublic void processMouseWheelEvent(MouseWheelEvent e)
processMouseWheelEvent in class Componentpublic void processEndEvent(GameEndEvent e)
GameEndListener objects.
public void addGameEndListener(GameEndListener listener)
Game. If the listener is null, no exception is thrown and no action is performed.
listener - the game end listenerpublic void removeGameEndListener(GameEndListener listener)
Game. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If the listener is null, no exception is thrown and no action is performed.
listener - the game end listenerpublic void addNotify()
addNotify in class Canvaspublic void removeNotify()
removeNotify in class Componentpublic Dimension getPreferredSize()
getPreferredSize in class Componentpublic Dimension getActingSize()
Component.getSize().
setActingSize(int, int)public int getActingWidth()
Component.getWidth().
setActingSize(int, int)public int getActingHeight()
Component.getHeight().
setActingSize(int, int)
public void setVirtualSize(int width,
int height)
setActingSize(int, int).
setActingSize(int, int)
public void setActingSize(int width,
int height)
If either width or height are <= 0, this will unset both values.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||