org.deken.game.animation
Class BounceAnimation

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

public class BounceAnimation
extends BaseAnimation
implements SoundListener

Title: BounceAnimationStrip Description: An animation strip for a game peice, that bounces from the first frame to the last frame, repeatedly. Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Field Summary
protected  boolean waitingForBounce
           
 
Fields inherited from class org.deken.game.animation.BaseAnimation
height, imageEffect, name, sequenceTime, sound, totalDuration, totalFrames, width, xOffset, yOffset
 
Constructor Summary
protected BounceAnimation()
          BounceAnimationStrip Used by copy().
  BounceAnimation(java.awt.Image image, long duration)
           
 
Method Summary
 void addFrame(java.awt.Image image, long duration)
          This adds an image to the animation strip, with a duration in milliseconds.
 BounceAnimation copy()
          Copy Animation
 void draw(java.awt.Graphics2D graphics, int x, int y)
          Draws the current frame index to the GameGFX, including any animation offsets.
 boolean equals(java.lang.Object obj)
          Determines if two animation strips are the same, based on size of image and number of frames.
 java.awt.Image getFrame(int i)
          This retrieves the specified frame.
 java.awt.Image getImage()
          This returns the current frame of the animated strip.
 boolean isAnimating()
          This animation strip will bounce forever.
 void notify(BaseSound.SEQUENCE sequence)
           
 void reset()
          This reset the animation strip, setting it to begin a new.
 void setBounceSound(boolean bounceSound)
           
 void setSound(TimeListeningSound sound)
          Sound element associated with this animation.
 void update(long elapseTime)
          This takes the elapse time, since the last update, and adds it to the total sequence time.
 
Methods inherited from class org.deken.game.animation.BaseAnimation
addImageEffect, baseUpdate, copyParent, getHeight, getName, getSound, getTotalDuration, getWidth, getXOffset, getYOffset, setName, setOffsets
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

waitingForBounce

protected boolean waitingForBounce
Constructor Detail

BounceAnimation

public BounceAnimation(java.awt.Image image,
                       long duration)
Parameters:
image - Image
duration - long

BounceAnimation

protected BounceAnimation()
BounceAnimationStrip Used by copy().

Method Detail

addFrame

public void addFrame(java.awt.Image image,
                     long duration)
This adds an image to the animation strip, with a duration in milliseconds.

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

copy

public BounceAnimation copy()
Copy Animation

Specified by:
copy in interface Animation
Returns:
BounceAnimationStrip

draw

public void draw(java.awt.Graphics2D graphics,
                 int x,
                 int y)
Draws the current frame index to the GameGFX, including any animation offsets.

Specified by:
draw in interface Animation
Parameters:
graphics -
x - int
y - int

equals

public boolean equals(java.lang.Object obj)
Determines if two animation strips are the same, based on size of image and number of frames.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object
Returns:
boolean

getFrame

public java.awt.Image getFrame(int i)
This retrieves the specified frame.

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

getImage

public java.awt.Image getImage()
This returns the current frame of the animated strip.

Specified by:
getImage in interface Animation
Returns:
Image

isAnimating

public boolean isAnimating()
This animation strip will bounce forever. This method will always return true.

Specified by:
isAnimating in interface Animation
Returns:
boolean

notify

public void notify(BaseSound.SEQUENCE sequence)
Specified by:
notify in interface SoundListener

reset

public void reset()
This reset the animation strip, setting it to begin a new.

Specified by:
reset in interface Animation

setBounceSound

public void setBounceSound(boolean bounceSound)
Parameters:
bounceSound -

setSound

public void setSound(TimeListeningSound sound)
Description copied from interface: Animation
Sound element associated with this animation. Start is the delta time that the sound should start playing at.

Specified by:
setSound in interface Animation
Overrides:
setSound in class BaseAnimation
Parameters:
sound -

update

public void update(long elapseTime)
This takes the elapse time, since the last update, and adds it to the total sequence time. If the duration is exceeded for a frame, the current frame index is increased.

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