|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gameframe.util.Counter
A counter that can display almost any number of digits. The counter uses
a rolling counter by default. In order to update the shown value you must
tick()
this counter. This causes the counter to adjust its
value towards the final value in steps (makes a nice rolling effect).
Methods addImmediately and decImmediately adjust the counter immediately.
The maximum number of digits this counter can show is the maximum number
of digits that can fit to an integer.
Field Summary | |
private int[] |
m_aCounts
Count for each of the 10 exp n values (n starts from 0 ). |
private DrawableBitmap[] |
m_aNumbers
The images that represent numbers. |
private int[] |
m_aX
The x coordinate for the count at index n. |
private int |
m_currentCount
The currently displayed value of this counter. |
private int |
m_destCount
The real value of this counter that it is rolling towards. |
private int |
m_fontHeight
The height of one font image. |
private int |
m_fontWidth
The width of one font image. |
private int |
m_initialCount
The initial count value, used when the counter is reset. |
private long |
m_lastTime
The last time player was ticked. |
private int |
m_numDigits
The number of digits (between 1 to 6) that are displayed. |
private int |
m_x
Base x-coordinate of the counter. |
private int |
m_y
Base y-coordinate of the counter. |
Constructor Summary | |
Counter(int initialCount,
int x,
int y,
int numDigits)
Constructs a counter that uses the currently set font bitmap for numbers, has the given initial value, is located at the given screen coordinates and uses the given number of digits. |
Method Summary | |
void |
add(int count)
Adds the given number to the counter. |
void |
addImmediately(int count)
Adds the given number to the counter immediately. |
void |
dec(int count)
Decrements the given number from the counter. |
void |
decImmediately(int count)
Decrements the given number from the counter immediately. |
int |
getCount()
Returns the current (real) counter value. |
int |
getHeight()
Returns the height of this counter. |
int |
getWidth()
Returns the width of this counter. |
int |
getX()
Returns the base x-coordinate of the counter based upon the number of digits it needs to display. |
int |
getY()
Returns the base y-coordinate. |
void |
paint()
Paints this counter to the backbuffer. |
void |
reset()
Resets this counter to its inital value. |
void |
setCount(int count)
Sets the count of this counter to the given number. |
void |
setImmediately(int count)
Sets the given counter value immediately without the fancy scrolling effect. |
void |
setX(int x)
Sets the upper left coordinate. |
void |
setY(int y)
Sets the upper left coordinate. |
void |
tick()
Calcultes the value of this counter every time called. |
private void |
updateCount()
Updates the number display values from the actual counter value. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int m_destCount
private int m_currentCount
private int m_initialCount
private int[] m_aCounts
private int[] m_aX
private int m_x
private int m_y
private int m_fontWidth
private int m_fontHeight
private DrawableBitmap[] m_aNumbers
private long m_lastTime
private int m_numDigits
Constructor Detail |
public Counter(int initialCount, int x, int y, int numDigits) throws GameFrameException
aNumbers
- The bitmaps that represent numbers.initialCount
- The initial counter value.x
- The base x-coordinate of the counter.y
- The base y-coordinate of the counter.numDigits
- The number of digits (between 1 to 6) that are displayed.Method Detail |
public void tick()
public void reset()
public void paint()
public int getCount()
public void add(int count)
count
- The number to add to this counter.public void addImmediately(int count)
count
- The number to add to this counter.public void dec(int count)
count
- The number to decrement from this counter.public void decImmediately(int count)
count
- The number to decrement from this counter.public void setCount(int count)
count
- The counters new value.public void setImmediately(int count)
private final void updateCount()
public int getX()
public void setX(int x)
x
- The x-coordinate this counter will use.public int getY()
public void setY(int y)
y
- The y-coordinate this counter will use.public int getWidth()
public int getHeight()
|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |