|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genuts.gameui.Sprite
com.genuts.gameui.ImageSequenceSprite
com.genuts.gameui.LCDSprite
This sprite is specially designed for games where is has definite positions.
The sprite is represented by its ID, and an array of positions in the playfield.
This sprite has to be used with the LCDCollisionManager. Collision
points have to be added by calling the method addCollisionPosition(int, int, int, int)
of the collision manager.
The animation should be continous be leaving displayed previous pictures of the sprite. See setContinuity(boolean)
.
LCDCollisionManager.addCollisionPosition(int, int, int, int)
,
setContinuity(boolean)
Constructor Summary | |
LCDSprite(int id,
java.awt.Image seq,
int nbh,
int nbv,
int[][] pos)
Initializes the sprite, with an sequence image. |
Method Summary | |
boolean |
checkCollision(Sprite sprite)
Checks collision position of this sprite with another collision from the other sprite. |
boolean |
getContinuity()
Indicates the continuity of pictures from the sequence. |
int |
getCurrentPosition()
Gets the current position. |
int[][] |
getPositions()
Gets positions for each sequence. |
protected void |
initContinuity()
Initializes continuity of pictures from the sequence. |
protected void |
initPosition()
Initializes the current X and Y position of the sprite. |
void |
nextPicture()
Changes the current displayed picture to the next one. |
void |
previousPicture()
Changes the current displayed picture to the previous one. |
protected void |
removeContinuity()
Removes continuity of pictures from the sequence. |
void |
setContinuity(boolean continuous)
Sets the continuity of pictures from the sequence. |
void |
setCurrentPictureNumber(int n)
Sets the current picture position in the sequence. |
void |
setCurrentPosition(int pos)
Sets the current position. |
void |
setHorizontalPicture(int nb)
Sets the current horizontal picture of the displayed image of the sequence. |
protected void |
setParent(PlayField parent)
Sets the parent playfield of this sprite. |
void |
setPositions(int[][] pos)
Sets positions for each sequence. |
void |
setSequence(java.awt.Image seq,
int nbh,
int nbv)
Sets the pictures sequence for this sprite. |
void |
setVerticalPicture(int nb)
Sets the current vertical picture of the displayed image of the sequence. |
java.lang.String |
toString()
Returns a string representation of this LCDSprite. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public LCDSprite(int id, java.awt.Image seq, int nbh, int nbv, int[][] pos)
id
- ID of this sprite.seq
- An image containing all pictures of the sequence.nbh
- Horizontaly number of pictures in the image.nbv
- Verticaly number of pictures in the image.pos
- X and Y positions for each sequence.Method Detail |
public void setPositions(int[][] pos)
pos
- X and Y posotion for each sequence.public int[][] getPositions()
public int getCurrentPosition()
ImageSequenceSprite.getCurrentPictureNumber()
public void setCurrentPosition(int pos)
pos
- The new current position of this spriteImageSequenceSprite.setCurrentPictureNumber(int)
protected void initPosition()
public void setSequence(java.awt.Image seq, int nbh, int nbv)
setSequence
in class ImageSequenceSprite
seq
- An image containing all pictures of the sequence.nbh
- Horizontaly number of pictures in the image.nbv
- Verticaly number of pictures in the image.public void setHorizontalPicture(int nb)
setHorizontalPicture
in class ImageSequenceSprite
nb
- the current horizontal picture.public void setVerticalPicture(int nb)
setVerticalPicture
in class ImageSequenceSprite
nb
- the current vertical picture.public void setCurrentPictureNumber(int n)
setCurrentPictureNumber
in class ImageSequenceSprite
n
- The current picture position in the sequence.public void nextPicture()
ImageSequenceSprite
isSequenceLoop()
is set to false
,
the sequence will not loop to the first picture and a call
to sequenceEnded()
will be performed, otherwise
the sequence will be loop.
nextPicture
in class ImageSequenceSprite
ImageSequenceSprite.sequenceEnded()
,
ImageSequenceSprite.isSequenceEnded()
public void previousPicture()
ImageSequenceSprite
isSequenceLoop()
is set to false
the sequence will not loop to the last picture and a call
to sequenceEnded()
will be performed, otherwise
the sequence will be loop.
previousPicture
in class ImageSequenceSprite
ImageSequenceSprite.sequenceEnded()
,
ImageSequenceSprite.isSequenceEnded()
public void setContinuity(boolean continuous)
continuous
- true
to indicate the
continuity of th sequence, false
otherwisepublic boolean getContinuity()
true
if sequence of pictures is continuous,
false
otherwise.protected void setParent(PlayField parent)
Sprite
setParent
in class Sprite
parent
- Parent playfield of this sprite.protected void initContinuity()
protected void removeContinuity()
public boolean checkCollision(Sprite sprite)
checkCollision
in class Sprite
sprite
- Sprite to check the collision with
true
if this sprite and the other
sprite are in collision, false
otherwisepublic java.lang.String toString()
toString
in class Sprite
|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |