GTGE API

com.golden.gamedev.object.background
Class ColorBackground

java.lang.Object
  extended by com.golden.gamedev.object.Background
      extended by com.golden.gamedev.object.background.ColorBackground
All Implemented Interfaces:
Serializable

public class ColorBackground
extends Background

The very basic background type that only fill the background view port with a single color.

This type of background use a fixed memory size. Memory used by small size color background (e.g: 1 x 1) with an extremely large size color background (e.g: 100,000,000 x 100,000,000) is equal.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.golden.gamedev.object.Background
screen, x, y
 
Constructor Summary
ColorBackground(Color bgColor)
          Creates new ColorBackground as large as screen dimension.
ColorBackground(Color bgColor, int w, int h)
          Creates new ColorBackground with specified size.
 
Method Summary
 Color getColor()
          Returns this background color.
 void render(Graphics2D g, int xbg, int ybg, int x, int y, int w, int h)
          Renders background from specified position and clipping area to specified graphics context.
 void setColor(Color bgColor)
          Sets the background color.
 
Methods inherited from class com.golden.gamedev.object.Background
getClip, getDefaultBackground, getHeight, getWidth, getX, getY, move, render, setClip, setClip, setLocation, setSize, setToCenter, setToCenter, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorBackground

public ColorBackground(Color bgColor,
                       int w,
                       int h)
Creates new ColorBackground with specified size.


ColorBackground

public ColorBackground(Color bgColor)
Creates new ColorBackground as large as screen dimension.

Method Detail

getColor

public Color getColor()
Returns this background color.


setColor

public void setColor(Color bgColor)
Sets the background color.


render

public void render(Graphics2D g,
                   int xbg,
                   int ybg,
                   int x,
                   int y,
                   int w,
                   int h)
Description copied from class: Background
Renders background from specified position and clipping area to specified graphics context.

This method to simplify background subclass rendering, the subclass only need to render the background from specified x, y coordinate with specified clipping area.

For example:

    Background backgr;
    Graphics2D g;

    backgr.render(g, 100, 100,
                  5, 10, 100, 200);
 
Means the background must render itself from background coordinate 100, 100 to specified graphics context, starting from 5, 10 screen pixel as large as 100 x 200 dimension.

Overrides:
render in class Background
Parameters:
g - graphics context
xbg - background x-coordinate
ybg - background y-coordinate
x - screen start x clipping
y - screen start y clipping
w - clipping width
h - clipping height

GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id