|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.genuts.gameui.SpriteDisplayManager
This display manager draws efficiently sprites in the playfield.
The display of the playfield is divided into cells, and only needed cells are redrawn when sprites move.
To be more efficient, this display manager redraws the whole playfield background at the first call, then for forthcoming calls, it redraws only changed parts of the background. Therefore, in paintPlayField(Graphics), you have to check the current clip of the graphics context.
PlayField.paintPlayField(Graphics)
Field Summary | |
(package private) boolean |
fullRedraw
|
Constructor Summary | |
SpriteDisplayManager(int step)
Initializes this display manager with a display step. |
Method Summary | |
void |
addSprite(Sprite sprite)
Adds a sprite in the display list of this display manager. |
void |
drawDebug(java.awt.Graphics g)
Draws debug informations for this display manager. |
int |
getDisplayStep()
Returns the display step check of this display manager. |
PlayField |
getPlayfield()
Returns the playfield associated with this display manager. |
void |
invalidateSprite(Sprite sprite)
Performs actions when a sprite is invalidate. |
void |
paint(java.awt.Graphics g)
Displays all visible elements of the playfield. |
void |
playfieldSizeChanged()
Informs that the size of the playfield has changed. |
void |
removeSprite(Sprite sprite)
Removes a sprite from the display list of this display manager. |
protected void |
repaintCell(int x,
int y)
Repaints a cell and all sprites contained. |
void |
reset()
Resets cache datas for this CollisionManager. |
void |
setDisplayStep(int step)
Sets the display step check of this display manager. |
void |
setPlayfield(PlayField playfield)
Sets the playfield associated with this display manager. |
void |
validateSprite(Sprite sprite)
Performs actions when a sprite is validate. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
boolean fullRedraw
Constructor Detail |
public SpriteDisplayManager(int step)
More the step is small, less sprites will be painted, but more steps will be needed to paint the playfield.
step
- Step for display.Method Detail |
public int getDisplayStep()
public void setDisplayStep(int step)
More the step is small, less sprites will be painted, but more steps will be needed to paint the playfield.
step
- The display step for this display manager.public PlayField getPlayfield()
DisplayManager
getPlayfield
in interface DisplayManager
public void setPlayfield(PlayField playfield)
DisplayManager
setPlayfield
in interface DisplayManager
playfield
- The playfield associated with this display manager.public void playfieldSizeChanged()
Be careful with sprites which are out the new size of the playfield, they are simply ignored.
playfieldSizeChanged
in interface DisplayManager
public void reset()
DisplayManager
reset
in interface DisplayManager
public void addSprite(Sprite sprite)
DisplayManager
Generally, this is called by the playfield when a new sprite is added.
addSprite
in interface DisplayManager
sprite
- Sprite to addpublic void removeSprite(Sprite sprite)
DisplayManager
Generally, this is called by the playfield when a sprite is removed.
removeSprite
in interface DisplayManager
sprite
- Sprite to removepublic void invalidateSprite(Sprite sprite)
DisplayManager
Generally, this is called by a sprite when Sprite.invalidate() is called.
invalidateSprite
in interface DisplayManager
sprite
- Sprite to invalidate.Sprite.invalidate()
public void validateSprite(Sprite sprite)
DisplayManager
Generally, this is called by a sprite when Sprite.validate() is called.
validateSprite
in interface DisplayManager
sprite
- Sprite to validate.Sprite.validate()
protected void repaintCell(int x, int y)
If a sprite is in several sprites, all of them are repainted recursivelly.
x
- X coodinate of the cell to repainty
- Y coodinate of the cell to repaintpublic void paint(java.awt.Graphics g)
For the playfield, calls the method paintPlayField(Graphics).
For each sprite, calls the method paint(Graphics).
paint
in interface DisplayManager
g
- The graphics context to use for painting.PlayField.paintPlayField(Graphics)
,
Sprite.paint(Graphics)
public void drawDebug(java.awt.Graphics g)
DisplayManager
drawDebug
in interface DisplayManager
g
- The graphics context to use for painting.
|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |