org.deken.game.animation
Class LayeredAnimation

java.lang.Object
  extended by org.deken.game.animation.BaseAnimation
      extended by org.deken.game.animation.LayeredAnimation
All Implemented Interfaces:
java.lang.Cloneable, Animation, ComplexAnimation, Updateable

public class LayeredAnimation
extends BaseAnimation
implements ComplexAnimation

Title: LayeredAnimation

Description: TODO

Copyright: Copyright (c) Nov 19, 2013

Version:
1.0
Author:
Gary Deken

Field Summary
 
Fields inherited from class org.deken.game.animation.BaseAnimation
height, imageEffect, name, sequenceTime, sound, totalDuration, totalFrames, width, xOffset, yOffset
 
Constructor Summary
LayeredAnimation(int numberOfLayers)
           
LayeredAnimation(java.util.List<Animation> animations)
           
 
Method Summary
 void addAnimation(int index, Animation animation)
           
 void addFrame(java.awt.Image image, long duration)
          This method is for adding an AnimationFrame to the animation strip.
 Animation copy()
          Copies the animation.
 void draw(java.awt.Graphics2D graphics, int x, int y)
          Draws the current frame or shape of the animation at the set x and y location.
 Animation getAnimation(int layer)
           
 java.awt.Image getFrame(int i)
          This method returns an Image at a given frame location.
 java.awt.Image getImage()
          This method returns the current frame of the animation.
 boolean isAnimating()
          True if this animation needs to be updated regularly.
 void reset()
          This resets the animation strip back to its default (or initial start) frame.
 void setAllLayers(boolean active)
          Deactivate all layers from rendering.
 void setLayerActive(int layer, boolean active)
          Sets a specific layer as active or inactive, depending on the value passed in.
 void update(long elapseTime)
          This method takes the elapse time, and calculates the new current frame of the animation.
 
Methods inherited from class org.deken.game.animation.BaseAnimation
addImageEffect, baseUpdate, copyParent, getHeight, getName, getSound, getTotalDuration, getWidth, getXOffset, getYOffset, setName, setOffsets, setSound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deken.game.animation.Animation
addImageEffect, getHeight, getSound, getTotalDuration, getWidth, getXOffset, getYOffset, setName, setOffsets, setSound
 
Methods inherited from interface org.deken.game.Updateable
getName
 

Constructor Detail

LayeredAnimation

public LayeredAnimation(int numberOfLayers)

LayeredAnimation

public LayeredAnimation(java.util.List<Animation> animations)
Method Detail

addAnimation

public void addAnimation(int index,
                         Animation animation)
Specified by:
addAnimation in interface ComplexAnimation

addFrame

public void addFrame(java.awt.Image image,
                     long duration)
Description copied from interface: Animation
This method is for adding an AnimationFrame to the animation strip.

Specified by:
addFrame in interface Animation
Parameters:
image - Image
duration - long

setAllLayers

public void setAllLayers(boolean active)
Deactivate all layers from rendering.

Parameters:
active -

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Description copied from interface: Animation
Draws the current frame or shape of the animation at the set x and y location. It also performs any offsets that are needed for the image.

Specified by:
draw in interface Animation

reset

public void reset()
Description copied from interface: Animation
This resets the animation strip back to its default (or initial start) frame. This is useful for starting a game piece back to the begining after it stops.

Specified by:
reset in interface Animation

update

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

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

getAnimation

public Animation getAnimation(int layer)

getFrame

public java.awt.Image getFrame(int i)
Description copied from interface: Animation
This method returns an Image at a given frame location. NOTE: this is useful for getting a static (stand still) image for a game piece.

Specified by:
getFrame in interface Animation
Parameters:
i - int
Returns:
Image

getImage

public java.awt.Image getImage()
Description copied from interface: Animation
This method returns the current frame of the animation. When it is used with the update method, it will return each image in the sequence as it is updated.

Specified by:
getImage in interface Animation
Returns:
Image

isAnimating

public boolean isAnimating()
Description copied from interface: Animation
True if this animation needs to be updated regularly. False if there is no animation to update, meaning getImage will return the same image.

Specified by:
isAnimating in interface Animation
Returns:
boolean

setLayerActive

public void setLayerActive(int layer,
                           boolean active)
Sets a specific layer as active or inactive, depending on the value passed in.

Parameters:
layer -
active -

copy

public Animation copy()
Description copied from interface: Animation
Copies the animation.

Specified by:
copy in interface Animation
Returns:
Animation