|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.object.Background
com.golden.gamedev.object.background.ParallaxBackground
public class ParallaxBackground
ParallaxBackground
class is a background composed by several
backgrounds.
This class automatically handles displaying and scrolling of the stacked backgrounds. The backgrounds are normalized to the size and position of the largest background in the stack. This way, the largest coordinate system is presented, and all backgrounds move together at a smooth rate.
The backgrounds is rendered from the first background on the stack to the last background on the stack, in other word the first background on the stack will be at the back of other backgrounds.
Parallax background usage example :
ParallaxBackground background; Background bg1, bg2, bg3; background = new ParallaxBackground(new Background[] { bg1, bg2, bg3 }); // bg1 is at the back of bg2 and bg2 is at the back of bg3
Field Summary |
---|
Fields inherited from class com.golden.gamedev.object.Background |
---|
screen, x, y |
Constructor Summary | |
---|---|
ParallaxBackground(Background[] stack)
Creates new ParallaxBackground . |
Method Summary | |
---|---|
Background[] |
getParallaxBackground()
Returns the stacked parallax backgrounds. |
void |
render(Graphics2D g)
Renders background to specified graphics context. |
void |
setLocation(double xb,
double yb)
Sets background location to specified coordinate. |
void |
setParallaxBackground(Background[] stack)
Sets parallax background stacked backgrounds. |
void |
update(long elapsedTime)
Updates this background, this method is usually used to create background animation or other special effect on the background. |
Methods inherited from class com.golden.gamedev.object.Background |
---|
getClip, getDefaultBackground, getHeight, getWidth, getX, getY, move, render, setClip, setClip, setSize, setToCenter, setToCenter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParallaxBackground(Background[] stack)
ParallaxBackground
.
Method Detail |
---|
public void setLocation(double xb, double yb)
Background
setLocation
in class Background
xb
- the x
coordinate of the backgroundyb
- the y
coordinate of the backgroundpublic void update(long elapsedTime)
Background
The implementation of this method provided by the Background
class does nothing.
update
in class Background
public void render(Graphics2D g)
Background
render
in class Background
g
- graphics contextpublic Background[] getParallaxBackground()
public void setParallaxBackground(Background[] stack)
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |