Genuts API

com.genuts.gameui
Class LCDAnimatedSprite

java.lang.Object
  |
  +--com.genuts.gameui.Sprite
        |
        +--com.genuts.gameui.ImageSequenceSprite
              |
              +--com.genuts.gameui.LCDSprite
                    |
                    +--com.genuts.gameui.LCDAnimatedSprite
All Implemented Interfaces:
Tickable

public class LCDAnimatedSprite
extends LCDSprite
implements Tickable

This sprite is an animation of pictures of a LCDSprite. Its goal is to provide an object to animate picture along the time with a sequence of pictures.

The animation should be done sequentially. This means that animation for all LCDAnimatedSprites is made in the tick, the order depends on their id. To activate this set the value of @{#setSequentialAnimation(booloean) setSequentialAnimation(booloean)} to true. That method is global to all LCDAnimatedSprites, if one of them is set to a sequential animation, all other too. And oppositely, if one is set to not have anymore a sequential animation, all other too.
To respect this, the frequence of the animation must be greater or equal to the number of LCDAnimatedSprites in the playfield.

See Also:
LCDSprite

Constructor Summary
LCDAnimatedSprite(int id, java.awt.Image anim, int nbh, int nbv, int[][] pos, int frequence)
          Initializes the sprite, with an animation image.
 
Method Summary
 void animate(int ticks)
          Animates the sprite as desired.
 int getCurrentRemindTick()
          Gets the value of currentTick.
 int getFrequence()
          Returns the number of ticks before a picture of the animation change.
 int getLCDAnimatedSpriteCount()
          Number of LCDAnimatedSprite in the parent playfield.
 boolean isSequentialAnimation()
          Indicates if the animation of all LCDAnimatedSprite is made sequentially.
 void setCurrentRemindTick(int v)
          Sets the value of currentTick.
 void setFrequence(int freq)
          Sets the number of ticks before a picture of the animation change.
protected  void setLCDAnimatedSpriteCount(int nb)
          Set the number of LCDAnimatedSprite in the parent playfield.
protected  void setParent(PlayField parent)
          Sets the parent playfield of this sprite.
 void setSequentialAnimation(boolean sequential)
          Sets if the animation of all LCDAnimatedSprite is made sequentially.
 void tick(int ticks)
          Receives a tick from the playfield to animate picture
 
Methods inherited from class com.genuts.gameui.LCDSprite
checkCollision, getContinuity, getCurrentPosition, getPositions, initContinuity, initPosition, nextPicture, previousPicture, removeContinuity, setContinuity, setCurrentPictureNumber, setCurrentPosition, setHorizontalPicture, setPositions, setSequence, setVerticalPicture, toString
 
Methods inherited from class com.genuts.gameui.ImageSequenceSprite
getCurrentPictureNumber, getHorizontalPicture, getHorizontalPicturesCount, getPicturesCount, getSequence, getVerticalPicture, getVerticalPicturesCount, isSequenceEnded, isSequenceLoop, paint, sequenceEnded, setSequenceEnded, setSequenceLoop
 
Methods inherited from class com.genuts.gameui.Sprite
collisionWith, getActionSprite, getBackground, getBottomCollisionOffset, getBounds, getFinalActionSprite, getFinalWrapper, getHeight, getId, getImage, getLeftCollisionOffset, getParent, getPosition, getRightCollisionOffset, getSize, getTopCollisionOffset, getWidth, getWrapper, getX, getY, invalidate, isBackgroundSprite, isPremode, isSpriteAt, isValidate, isVisible, preCollisionWith, repaint, setBackground, setBackgroundSprite, setBottomCollisionOffset, setBounds, setBounds, setId, setImage, setLeftCollisionOffset, setPosition, setPremode, setRightCollisionOffset, setSize, setTopCollisionOffset, setVisible, setWrapper, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LCDAnimatedSprite

public LCDAnimatedSprite(int id,
                         java.awt.Image anim,
                         int nbh,
                         int nbv,
                         int[][] pos,
                         int frequence)
Initializes the sprite, with an animation image.
The image is composed with all pictures of the animation.

Parameters:
id - ID of this sprite.
anim - An image containing all pictures of the animation.
nbh - Horizontally number of pictures in the image.
nbv - Vertically number of pictures in the image.
pos - X and Y posotion for each sequence.
frequence - Number of ticks to wait before to change a picture.
Method Detail

getFrequence

public int getFrequence()
Returns the number of ticks before a picture of the animation change.

Returns:
The number of ticks before a picture change, or -1 if the picture does not change.

setFrequence

public void setFrequence(int freq)
Sets the number of ticks before a picture of the animation change.

Parameters:
freq - The number of ticks before a picture change, or -1 if the picture does not change.

getCurrentRemindTick

public int getCurrentRemindTick()
Gets the value of currentTick.

Returns:
value of currentTick.

setCurrentRemindTick

public void setCurrentRemindTick(int v)
Sets the value of currentTick.

Parameters:
v - Value to assign to currentTick.

getLCDAnimatedSpriteCount

public int getLCDAnimatedSpriteCount()
Number of LCDAnimatedSprite in the parent playfield.

Returns:
The number of LCDAnimatedSprite in the parent playfield.

setLCDAnimatedSpriteCount

protected void setLCDAnimatedSpriteCount(int nb)
Set the number of LCDAnimatedSprite in the parent playfield.

Parameters:
nb - The new number of LCDAnimatedSprite in the parent playfield.

isSequentialAnimation

public boolean isSequentialAnimation()
Indicates if the animation of all LCDAnimatedSprite is made sequentially.

Returns:
true if the animation is made sequentially, false otherwise.

setSequentialAnimation

public void setSequentialAnimation(boolean sequential)
Sets if the animation of all LCDAnimatedSprite is made sequentially.

Parameters:
sequential - true if the animation is made sequentially, false otherwise.

setParent

protected void setParent(PlayField parent)
Description copied from class: Sprite
Sets the parent playfield of this sprite.

Overrides:
setParent in class LCDSprite
Parameters:
parent - Parent playfield of this sprite.

tick

public void tick(int ticks)
Receives a tick from the playfield to animate picture

Specified by:
tick in interface Tickable
Parameters:
ticks - Tick number from the playfield.

animate

public void animate(int ticks)
Animates the sprite as desired.
By default, it moves to the next picture.

Parameters:
ticks - Number of ticks from the playfield

Genuts API

Genuts API