|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.genuts.gameui.Sprite | +--com.genuts.gameui.SpriteLabel | +--com.genuts.gameui.SpriteCounter
This object is for representation of all counter types such player's score.
It inherits from SpriteLabel
to be able to inserted in a
PlayField
. By default, the counter is a background
sprite.
To represent digits, the counter use the default font of the playfield.
You can 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.
Constructor Summary | |
SpriteCounter()
Initializes the counter. |
|
SpriteCounter(int digitsCount)
Initializes the counter with a specified number of digits to display. |
Method Summary | |
void |
addValue(int value)
Adds a value to the value of this counter. |
int |
getDigitsCount()
Gets the number of digits to display. |
int |
getMaximumValue()
Gets the maximum value of this counter. |
int |
getValue()
Gets the value of this counter. |
protected void |
initSprite()
Initializes the counter sprite. |
boolean |
isDisplayAllDigits()
Indicates if all digits are displayed. |
void |
setDigitsCount(int digitsCount)
Sets the number of digits to display. |
void |
setDisplayAllDigits(boolean display)
Are all digits displayed? |
void |
setMaximumValue(int maxValue)
Sets the maximum value for this counter. |
void |
setValue(int value)
Sets the value of this counter. |
void |
subValue(int value)
Subs a value to the value of this counter. |
Methods inherited from class com.genuts.gameui.SpriteLabel |
getBaseline, getColor, getFont, getText, paint, setBaseline, setColor, setFont, setParent, setText |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SpriteCounter()
public SpriteCounter(int digitsCount)
digitsCount
- Number of digits to display.Method Detail |
public void setDigitsCount(int digitsCount)
Initializes the maximum value of this counter with yhe right value of digits.
digitsCount
- Number of digits to display
java.lang.IllegalAccessError
- if the numberdigits to display is lower than 1.public int getDigitsCount()
public void setMaximumValue(int maxValue)
maxValue
- The maximum value for this counter.public int getMaximumValue()
protected void initSprite()
initSprite
in class SpriteLabel
public void setValue(int value)
If the value is greater than the max value,
value is equal to value
modulus maxValue
.
value
- Value to set.public int getValue()
public void addValue(int value)
value
- Value to add.public void subValue(int value)
value
- Value to sub.public void setDisplayAllDigits(boolean display)
display
- true
to display not
used digits, false
otherwise.public boolean isDisplayAllDigits()
true
to display not
used digits, false
otherwise.
|
Genuts API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |