|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.golden.gamedev.object.PlayField
Game arena, behave as the game manager.
All SpriteGroup
and CollisionGroupManager
is stored here.
By calling update()
all sprites will be updated and
collision also checked. By calling render(Graphics2D)
all sprites is rendered into graphics context.
Constructor Summary | |
PlayField()
|
|
PlayField(Background backgr)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PlayField(Background backgr)
public PlayField()
Method Detail |
public void add(Sprite extra)
SpriteGroup
for the sprite.
public SpriteGroup addGroup(SpriteGroup group)
SpriteGroup
into this playfield.
The returned sprite group is the reference of the inserted group,
used for code reduce and simplicity. Playfield playfield = new Playfield(); SpriteGroup PLAYER = playfield.addGroup(new SpriteGroup("Player"));If there's no returned reference, we must set the sprite group and add it manually into playfield, like this:
Playfield playfield = new Playfield(); SpriteGroup PLAYER = new SpriteGroup("Player"); playfield.addGroup(PLAYER);
public boolean removeGroup(SpriteGroup group)
public SpriteGroup getGroup(String name)
public SpriteGroup[] getGroups()
public void addCollisionGroup(SpriteGroup group1, SpriteGroup group2, CollisionGroupManager collisionGroup)
public boolean removeCollisionGroup(CollisionGroupManager collisionGroup)
public CollisionGroupManager getCollisionGroup(SpriteGroup group1, SpriteGroup group2)
public CollisionGroupManager getCollisionGroup(SpriteGroup group)
public CollisionGroupManager[] getCollisionGroups()
public void update()
protected void updateBackground()
protected void updateSprites()
protected void checkCollisions()
public void render(Graphics2D g)
protected void renderBackground(Graphics2D g)
protected void renderSprites(Graphics2D g)
protected void renderSprites(Graphics2D g, Comparator c)
c
before render it.
public void clearCache()
Cache sprite is used to keep sprites in sorted order,
that will be used on rendering sprite with comparator.
When method renderSprites(Graphics2D, Comparator)
called,
all sprite that visible on scren are stored in cache and then sorted,
Therefore after rendering done, the cache still remain in memory
and wait to be cached again on next rendering.
This method simply clears the cache sprite. Call this method when sort rendering is not needed anymore.
renderSprites(Graphics2D, Comparator)
public Background getBackground()
public void setBackground(Background backgr)
public Comparator getComparator()
public void setComparator(Comparator c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |