|
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.ScrollingImageSprite
A scrolling image sprite is a background sprite in which an image scrolls with a given speed.
If the image is smaller than the size of the sprite, the image is
redrawn to fill the sprite size.
When the scroll comes to one edge, the image is redrawn to
continue the scrolling.
The speed of the scrolling can be defined on Y and Y coordinates.
Field Summary | |
protected java.awt.Image |
scrollingImage
Image on with the scrolling is made. |
protected int |
xScrollingPos
Current X possition in scrollingImage. |
protected int |
yScrollingPos
Current Y possition in scrollingImage. |
Constructor Summary | |
ScrollingImageSprite(int w,
int h,
java.awt.Image image,
int vx,
int vy)
Initialises the scrolling sprite. |
Method Summary | |
java.awt.Image |
getScrollingImage()
Gets the image for the scrolling. |
java.awt.Point |
getSpeed()
Returns the speed of the scrolling. |
protected void |
initScrollingImage()
Initialise scrollingImage. |
void |
paint(java.awt.Graphics g)
Paint this scrolling sprite. |
void |
setScrollingImage(java.awt.Image image)
Sets the image for the scrolling. |
void |
setScrollingSpeed(int vx,
int vy)
Sets speed of the scrolling. |
boolean |
setSize(int w,
int h)
Sets the size of this sprite. |
void |
tick(int ticks)
The object receives a tick as desired. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.awt.Image scrollingImage
protected int xScrollingPos
protected int yScrollingPos
Constructor Detail |
public ScrollingImageSprite(int w, int h, java.awt.Image image, int vx, int vy)
w
- Width of the sprite.h
- height of the sprite.image
- Image for scrolling.vx
- Speed on X coordinate.vy
- Speed on Y coordinate.Method Detail |
public void setScrollingImage(java.awt.Image image)
image
- Image for the scrolling.public java.awt.Image getScrollingImage()
public boolean setSize(int w, int h)
setSize
in class Sprite
true
if the modification was done, false
otherwise.public void setScrollingSpeed(int vx, int vy)
vx
- Speed on X coordinate.vy
- Speed on Y coordinate.public java.awt.Point getSpeed()
Point
where
Point.x represent the speed for X coordinate,
and Point.y represent the speed for Y coordinate.protected void initScrollingImage()
public void tick(int ticks)
Tickable
tick
in interface Tickable
ticks
- Tick number from the playfield.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 |