Genuts API

com.genuts.gameui
Class SpriteImageCounter

java.lang.Object
  |
  +--com.genuts.gameui.Sprite
        |
        +--com.genuts.gameui.SpriteLabel
              |
              +--com.genuts.gameui.SpriteCounter
                    |
                    +--com.genuts.gameui.SpriteImageCounter
All Implemented Interfaces:
java.lang.Cloneable

public class SpriteImageCounter
extends SpriteCounter

This object is for representation of all counter type such player's score with an image.

To represent digits, the counter use a big image with 10 digits. For example, you can use this image:

You have to specify the number of digit to display, by default, it is 3, and it will resize the component automaticly.
You have the ability to display all digits of the counter, or not to display 0 value on the left side. By default, the counter desn't display all digits.

See Also:
SpriteCounter

Constructor Summary
SpriteImageCounter(java.awt.Image digits, int nbh, int nbv)
          Initializes the counter with an image of digits.
SpriteImageCounter(java.awt.Image digits, int nbh, int nbv, int digitsCount)
          Initializes the counter with an image of digits and a specified number of digits to display.
 
Method Summary
 java.awt.Image getDigitsImage()
          Gets the digits from the image for this counter.
 int getHorizontalPictures()
          Gets the number of pictures contained horizontally in the image of digits.
 int getVerticalPictures()
          Gets the number of pictures contained vertically in the image of digits.
protected  void initSprite()
          Initializes the counter sprite.
 void paint(java.awt.Graphics g)
          Paint this counter.
 void setDigitsImage(java.awt.Image digits, int nbh, int nbv)
          Sets the image of digits for this counter.
 
Methods inherited from class com.genuts.gameui.SpriteCounter
addValue, getDigitsCount, getMaximumValue, getValue, isDisplayAllDigits, setDigitsCount, setDisplayAllDigits, setMaximumValue, setValue, subValue
 
Methods inherited from class com.genuts.gameui.SpriteLabel
getBaseline, getColor, getFont, getText, setBaseline, setColor, setFont, setParent, setText
 
Methods inherited from class com.genuts.gameui.Sprite
checkCollision, cloneSprite, 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, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpriteImageCounter

public SpriteImageCounter(java.awt.Image digits,
                          int nbh,
                          int nbv)
Initializes the counter with an image of digits.
The image is composed with 10 pictures of digits.

Parameters:
digits - An image containing 10 pictures of digits.
nbh - Horizontaly number of pictures in the image.
nbv - Verticaly number of pictures in the image.

SpriteImageCounter

public SpriteImageCounter(java.awt.Image digits,
                          int nbh,
                          int nbv,
                          int digitsCount)
Initializes the counter with an image of digits and a specified number of digits to display.
The image is composed with 10 pictures of digits.

Parameters:
digits - An image containing 10 pictures of digits.
nbh - Horizontaly number of pictures in the image.
nbv - Verticaly number of pictures in the image.
digitsCount - Number of digits to display.
Method Detail

getDigitsImage

public java.awt.Image getDigitsImage()
Gets the digits from the image for this counter.

Returns:
An image containing all pictures of digits.

getHorizontalPictures

public int getHorizontalPictures()
Gets the number of pictures contained horizontally in the image of digits.

Returns:
The number of pictures contained horizontally in the image of digits.

getVerticalPictures

public int getVerticalPictures()
Gets the number of pictures contained vertically in the image of digits.

Returns:
The number of pictures contained vertically in the image of digits.

setDigitsImage

public void setDigitsImage(java.awt.Image digits,
                           int nbh,
                           int nbv)
Sets the image of digits for this counter.
The number of pictures (i.e. nbh*nbv) mustbe equal to 10.

Parameters:
digits - An image containing 10 pictures of digits.
nbh - Horizontaly number of pictures in the image.
nbv - Verticaly number of pictures in the image.
Throws:
java.lang.IllegalAccessError - if nbh or nbv is equal to 0 or if the number of picture is not equal to 10.

initSprite

protected void initSprite()
Description copied from class: SpriteCounter
Initializes the counter sprite.

Overrides:
initSprite in class SpriteCounter

paint

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

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

Genuts API

Genuts API