Genuts API

com.genuts.gameui
Class ScrollingImageSprite

java.lang.Object
  |
  +--com.genuts.gameui.Sprite
        |
        +--com.genuts.gameui.ScrollingImageSprite
All Implemented Interfaces:
Tickable
Direct Known Subclasses:
ScrollingTransparentImageSprite

public class ScrollingImageSprite
extends Sprite
implements Tickable

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 com.genuts.gameui.Sprite
checkCollision, 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, setParent, setPosition, setPremode, setRightCollisionOffset, setTopCollisionOffset, setVisible, setWrapper, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scrollingImage

protected java.awt.Image scrollingImage
Image on with the scrolling is made.


xScrollingPos

protected int xScrollingPos
Current X possition in scrollingImage.


yScrollingPos

protected int yScrollingPos
Current Y possition in scrollingImage.

Constructor Detail

ScrollingImageSprite

public ScrollingImageSprite(int w,
                            int h,
                            java.awt.Image image,
                            int vx,
                            int vy)
Initialises the scrolling sprite.

Parameters:
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

setScrollingImage

public void setScrollingImage(java.awt.Image image)
Sets the image for the scrolling.

Parameters:
image - Image for the scrolling.

getScrollingImage

public java.awt.Image getScrollingImage()
Gets the image for the scrolling.

Returns:
Image for the scrolling.

setSize

public boolean setSize(int w,
                       int h)
Sets the size of this sprite.

Overrides:
setSize in class Sprite
Returns:
true if the modification was done, false otherwise.

setScrollingSpeed

public void setScrollingSpeed(int vx,
                              int vy)
Sets speed of the scrolling.

Parameters:
vx - Speed on X coordinate.
vy - Speed on Y coordinate.

getSpeed

public java.awt.Point getSpeed()
Returns the speed of the scrolling.

Returns:
an instance of Point where Point.x represent the speed for X coordinate, and Point.y represent the speed for Y coordinate.

initScrollingImage

protected void initScrollingImage()
Initialise scrollingImage.


tick

public void tick(int ticks)
Description copied from interface: Tickable
The object receives a tick as desired.

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

paint

public void paint(java.awt.Graphics g)
Paint this scrolling sprite.

Overrides:
paint in class Sprite
Parameters:
g - The graphics context to use for painting.

Genuts API

Genuts API