|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmhframework.MHScreen
public abstract class MHScreen
This is an abstract base class for deriving game screens. It provides the following required pieces:
How to create a new game screen:
And that's it! The screen manager (MHScreenManager) will hold the screen while the game class (MHGame) runs it. Note that neither MHScreenManager nor MHGame need to be extended. They were designed to work autonomously in their current forms.
How to change screens in an application:
Constructor Summary | |
---|---|
MHScreen()
Default constructor. |
Method Summary | |
---|---|
void |
add(MHGUIComponent c)
Adds an MHGUIComponent object to the screen. |
void |
advance()
Tells an object to update its data. |
void |
centerText(java.awt.Graphics g,
java.lang.String text,
int y,
java.awt.Color c,
boolean shadowed,
int shadowDistance)
|
MHGUIComponentList |
getComponentList()
|
MHGUIComponent |
getFocusedComponent()
Return a reference to the GUI component that currently has the focus. |
MHScreen |
getNextScreen()
Returns a reference to the next screen to be pushed. |
MHScreen |
getPreviousScreen()
|
void |
hideErrorMessage()
|
boolean |
isDisposable()
|
boolean |
isFinished()
Returns the value of the "finished" flag. |
void |
keyPressed(java.awt.event.KeyEvent e)
Delivers Key Pressed events to the GUI components. |
void |
keyReleased(java.awt.event.KeyEvent e)
Delivers Key Released events to the GUI components. |
void |
keyTyped(java.awt.event.KeyEvent e)
Delivers Key Typed events to the GUI components. |
abstract void |
load()
Set up a screen and prepare it to run. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Delivers Mouse Clicked events to the GUI components. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Delivers Mouse Moved events to the GUI components. |
void |
mousePressed(java.awt.event.MouseEvent e)
Delivers Mouse Pressed events to the GUI components. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Delivers Mouse Released events to the GUI components. |
void |
nextFocusableComponent()
Sets the focus to the next component capable of receiving focus. |
void |
prevFocusableComponent()
Sets the focus to the previous component capable of receiving focus. |
void |
remove(MHGUIComponent c)
Removes an MHGUIComponent object from the screen. |
void |
render(java.awt.Graphics2D g)
Draws the GUI components onto the sent Graphics object. |
void |
setDisposable(boolean disposable)
|
void |
setFinished(boolean f)
Sets the value of the "finished" flag to the input parameter. |
void |
setNextScreen(MHScreen nextScreen)
Sets a reference to the next screen to be pushed when this one is finished. |
void |
setPreviousScreen(MHScreen previous)
|
void |
showErrorMessage(java.lang.String text)
|
static void |
tileImage(java.awt.Graphics2D g,
java.awt.Image image,
int x,
int y)
|
abstract void |
unload()
Perform termination housekeeping or reset the screen variables when a screen has finished executing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.ActionListener |
---|
actionPerformed |
Constructor Detail |
---|
public MHScreen()
Method Detail |
---|
public MHGUIComponentList getComponentList()
public abstract void load()
public abstract void unload()
public void add(MHGUIComponent c)
c
- The component to be addedpublic void remove(MHGUIComponent c)
c
- The component to be removedpublic MHGUIComponent getFocusedComponent()
public void nextFocusableComponent()
public void prevFocusableComponent()
public void setNextScreen(MHScreen nextScreen)
nextScreen
- The next screen to be displayedpublic MHScreen getNextScreen()
public void render(java.awt.Graphics2D g)
render
in interface MHRenderable
g
- The Graphics object on which this object is to draw itself.public void advance()
MHRenderable
advance
in interface MHRenderable
public void centerText(java.awt.Graphics g, java.lang.String text, int y, java.awt.Color c, boolean shadowed, int shadowDistance)
public void showErrorMessage(java.lang.String text)
public void hideErrorMessage()
public void setFinished(boolean f)
public boolean isFinished()
public boolean isDisposable()
public void setDisposable(boolean disposable)
disposable
- A flag to indicate that screen can be deallocated.public static void tileImage(java.awt.Graphics2D g, java.awt.Image image, int x, int y)
public void keyPressed(java.awt.event.KeyEvent e)
e
- The event that triggered a call to this method.public void keyReleased(java.awt.event.KeyEvent e)
e
- The event that triggered a call to this method.public void keyTyped(java.awt.event.KeyEvent e)
e
- The event that triggered a call to this method.public void mousePressed(java.awt.event.MouseEvent e)
e
- The event that triggered a call to this method.public void mouseReleased(java.awt.event.MouseEvent e)
e
- The event that triggered a call to this method.public void mouseClicked(java.awt.event.MouseEvent e)
e
- The event that triggered a call to this method.public void mouseMoved(java.awt.event.MouseEvent e)
e
- The event that triggered a call to this method.public MHScreen getPreviousScreen()
public void setPreviousScreen(MHScreen previous)
previous
- the previous to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |