|
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
This sprite is a sequence of pictures from one image. It gives an easy way to display next picture or previous picture.
The image sequence is composed of ordered picture for the left to the rigtht, and from the top to bottom. All pictures have the same size.
For example, we can use this image:
![]() |
Number of pictures horizontally: 4 Number of pictures vertically: 3 |
Sprite sprite = new ImageSequenceSprite(image, 4, 3);
The sequence of pictures can loop, and provides a cyclic continuation of pictures. Otherwise, the sprite can be advise if the sequence ended.
setSequenceLoop(boolean)
,
sequenceEnded()
,
isSequenceEnded()
Constructor Summary | |
ImageSequenceSprite(java.awt.Image seq,
int nbh,
int nbv)
Initializes the sprite, with a sequence image. |
Method Summary | |
int |
getCurrentPictureNumber()
Gets the current picture index in the image sequence. |
int |
getHorizontalPicture()
Returns the current horizontal index of the displayed picture in the image. |
int |
getHorizontalPicturesCount()
Gets the number of pictures contained horizontally in the sequence image. |
int |
getPicturesCount()
Gets the number of pictures contained in the sequence image. |
java.awt.Image |
getSequence()
Gets the sequence image for this sprite. |
int |
getVerticalPicture()
Returns the current vertical index of the displayed picture in the image. |
int |
getVerticalPicturesCount()
Gets the number of pictures contained vertically in the sequence image. |
boolean |
isSequenceEnded()
Indicates that the sequence loop ended. |
boolean |
isSequenceLoop()
Is the sequence loops continously or stop on the last image? |
void |
nextPicture()
Changes the current displayed picture to the next one. |
void |
paint(java.awt.Graphics g)
Draws the current picture for this sprite. |
void |
previousPicture()
Changes the current displayed picture to the previous one. |
protected void |
sequenceEnded()
Indicates that the sequence ended. |
void |
setCurrentPictureNumber(int n)
Sets the current picture position in the image sequence. |
void |
setHorizontalPicture(int nb)
Sets the current horizontal index of the displayed picture in the image. |
void |
setSequence(java.awt.Image seq,
int nbh,
int nbv)
Sets the pictures seqeunce for this sprite. |
protected void |
setSequenceEnded(boolean end)
Sets if the sequence loop ended. |
void |
setSequenceLoop(boolean v)
Sets if the sequence loops or stop on the last image. |
void |
setVerticalPicture(int nb)
Sets the current vertical index of the displayed picture in the image. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ImageSequenceSprite(java.awt.Image seq, int nbh, int nbv)
seq
- An image containing all pictures of the sequencenbh
- Horizontaly number of pictures in the imagenbv
- Verticaly number of pictures in the imageMethod Detail |
public java.awt.Image getSequence()
public int getPicturesCount()
public int getHorizontalPicturesCount()
public int getVerticalPicturesCount()
public void setSequence(java.awt.Image seq, int nbh, int nbv)
The current picture number is inchanged, except it is greater than the new number of pictures, in that case, it is placed to the last picture.
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.
java.lang.IllegalAccessError
- if nbh or nbv is equal to 0.public boolean isSequenceLoop()
sequenceEnded()
is performed.
true
if the sequence loops, false
otherwise.sequenceEnded()
,
isSequenceEnded()
public void setSequenceLoop(boolean v)
v
- true
if the sequence loops, false
otherwise.public int getHorizontalPicture()
public void setHorizontalPicture(int nb)
nb
- the current horizontal picture.public int getVerticalPicture()
public void setVerticalPicture(int nb)
nb
- the current vertical picture.public int getCurrentPictureNumber()
public void setCurrentPictureNumber(int n)
n
- The current picture position in the image sequence.public void nextPicture()
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.
sequenceEnded()
,
isSequenceEnded()
public void previousPicture()
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.
sequenceEnded()
,
isSequenceEnded()
public boolean isSequenceEnded()
true
if the sequence ended, false
otherwise.protected void setSequenceEnded(boolean end)
end
- true
if the sequence end,
false
otherwise.protected void sequenceEnded()
public void paint(java.awt.Graphics g)
paint
in class Sprite
g
- The graphics context to use for painting.
|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |