GTGE API

com.golden.gamedev.object.background
Class ImageBackground

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

public class ImageBackground
extends Background

Background that use a single image as the background.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.golden.gamedev.object.Background
screen, x, y
 
Constructor Summary
ImageBackground(BufferedImage image)
          Creates new ImageBackground with specified image and the background size is as large as the image.
ImageBackground(BufferedImage image, int w, int h)
          Creates new ImageBackground with specified image and background size.
 
Method Summary
 BufferedImage getImage()
          Returns this background image.
 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 setImage(BufferedImage image)
          Sets this background image, and the size of this background is set to the image size.
 
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

ImageBackground

public ImageBackground(BufferedImage image,
                       int w,
                       int h)
Creates new ImageBackground with specified image and background size.


ImageBackground

public ImageBackground(BufferedImage image)
Creates new ImageBackground with specified image and the background size is as large as the image.

Method Detail

getImage

public BufferedImage getImage()
Returns this background image.


setImage

public void setImage(BufferedImage image)
Sets this background image, and the size of this background is set to the image size.


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