com.golden.gamedev.object
Class Background

java.lang.Object
  |
  +--com.golden.gamedev.object.Background
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractTileBackground, ColorBackground, ImageBackground

public class Background
extends Object
implements Serializable

Background where Sprites lived. A sprite is located somewhere on its background.

See Also:
Serialized Form

Field Summary
static Dimension screen
          Screen resolution dimension.
 
Constructor Summary
Background()
          Creates new Background, with size and clipping area as large as screen size.
Background(int w, int h)
          Creates new Background with specified size, and default clipping area (as large as screen size).
 
Method Summary
 Rectangle getClip()
           
static Background getDefaultBackground()
           
 int getHeight()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
 void move(int dx, int dy)
           
 void render(Graphics2D g)
           
 void render(Graphics2D g, int xbg, int ybg, int x, int y, int w, int h)
           
 void setClip(int x, int y, int width, int height)
          Sets background clipping area, the default is as large as screen size.
 void setLocation(int xs, int ys)
           
 void setSize(int w, int h)
           
 void setToCenter(int x, int y, int w, int h)
           
 void setToCenter(Sprite centered)
           
 void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

screen

public static Dimension screen
Screen resolution dimension. Used for determine background clipping area. Default value: 640x480.

See Also:
setClip(int, int, int, int)
Constructor Detail

Background

public Background(int w,
                  int h)
Creates new Background with specified size, and default clipping area (as large as screen size).


Background

public Background()
Creates new Background, with size and clipping area as large as screen size.

Method Detail

getDefaultBackground

public static Background getDefaultBackground()

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Sets background clipping area, the default is as large as screen size.

See Also:
screen

getClip

public Rectangle getClip()

getX

public int getX()

getY

public int getY()

getWidth

public int getWidth()

getHeight

public int getHeight()

setSize

public void setSize(int w,
                    int h)

setLocation

public void setLocation(int xs,
                        int ys)

move

public void move(int dx,
                 int dy)

setToCenter

public void setToCenter(int x,
                        int y,
                        int w,
                        int h)

setToCenter

public void setToCenter(Sprite centered)

update

public void update()

render

public void render(Graphics2D g)

render

public void render(Graphics2D g,
                   int xbg,
                   int ybg,
                   int x,
                   int y,
                   int w,
                   int h)