org.deken.game.background
Class LayeredBackground

java.lang.Object
  extended by org.deken.game.background.LayeredBackground
All Implemented Interfaces:
Background, Updateable

public class LayeredBackground
extends java.lang.Object
implements Background

Title: LayeredBackground

Description: LayeredBackground stores Backgrounds in a layer, where element 0 is the bottom layer and higher numbers are above.

Copyright: Copyright (c) Jul 5, 2014

Version:
1.0
Author:
Gary Deken

Constructor Summary
LayeredBackground()
           
LayeredBackground(Animation animation)
           
 
Method Summary
 void addAnimation(Animation animation)
          Adds a FixedBackground in the next layer up.
 void addBackground(Background background)
          Adds the Background to the top of the layers.
 void addBackground(int layer, Background background)
          Adds the Background at the specified layer.
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the back ground based on the current offset of the map, and the Backgrounds equation for calculating its position.
 java.lang.String getName()
           
 void setMapSize(MapSize mapSize)
          Set the map size, so the back ground can be adjusted accordingly.
 void setScreenSize(int width, int height)
          Set the screen size, so the back ground can be adjusted accordingly.
 void update(long elapseTime)
          This method takes the elapse time, and calculates the new current frame of the animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayeredBackground

public LayeredBackground()

LayeredBackground

public LayeredBackground(Animation animation)
Method Detail

addAnimation

public void addAnimation(Animation animation)
Adds a FixedBackground in the next layer up.

Specified by:
addAnimation in interface Background
Parameters:
animation -

addBackground

public void addBackground(Background background)
Adds the Background to the top of the layers.

Parameters:
background -

addBackground

public void addBackground(int layer,
                          Background background)
Adds the Background at the specified layer. If the specified layer is larger then the list size, it adds it to the end.

Parameters:
layer -
background -

draw

public void draw(java.awt.Graphics2D graphics,
                 int xOffset,
                 int yOffset)
Description copied from interface: Background
Draws the back ground based on the current offset of the map, and the Backgrounds equation for calculating its position.

Specified by:
draw in interface Background
xOffset - int
yOffset - int

getName

public java.lang.String getName()
Specified by:
getName in interface Updateable
Returns:

setMapSize

public void setMapSize(MapSize mapSize)
Description copied from interface: Background
Set the map size, so the back ground can be adjusted accordingly.

Specified by:
setMapSize in interface Background
Parameters:
mapSize - int

setScreenSize

public void setScreenSize(int width,
                          int height)
Description copied from interface: Background
Set the screen size, so the back ground can be adjusted accordingly.

Specified by:
setScreenSize in interface Background
Parameters:
width - int
height - int

update

public void update(long elapseTime)
Description copied from interface: Updateable
This method takes the elapse time, and calculates the new current frame of the animation.

Specified by:
update in interface Updateable
Parameters:
elapseTime - long