GF4J 0.9.4 Beta

gameframe.util
Class Counter

java.lang.Object
  |
  +--gameframe.util.Counter

public class Counter
extends java.lang.Object

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.

Since:
GameFrame for Java 0.9.4
Version:
GameFrame for Java 0.9.4
Author:
Pasi Keränen 15. Jul 2000

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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counter

public Counter(int initialCount,
               int x,
               int y,
               int numDigits)
        throws GameFrameException
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.
Parameters:
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

tick

public void tick()
Calcultes the value of this counter every time called.

reset

public void reset()
Resets this counter to its inital value.

paint

public void paint()
Paints this counter to the backbuffer.

getCount

public int getCount()
Returns the current (real) counter value.
Returns:
The current counter value.

add

public void add(int count)
Adds the given number to the counter.
Parameters:
count - The number to add to this counter.

addImmediately

public void addImmediately(int count)
Adds the given number to the counter immediately.
Parameters:
count - The number to add to this counter.

dec

public void dec(int count)
Decrements the given number from the counter.
Parameters:
count - The number to decrement from this counter.

decImmediately

public void decImmediately(int count)
Decrements the given number from the counter immediately.
Parameters:
count - The number to decrement from this counter.

setCount

public void setCount(int count)
Sets the count of this counter to the given number.
Parameters:
count - The counters new value.

setImmediately

public void setImmediately(int count)
Sets the given counter value immediately without the fancy scrolling effect.

getX

public int getX()
Returns the base x-coordinate of the counter based upon the number of digits it needs to display. The base coordinate is the leftmost numbers coordinate.
Returns:
The base x-coordinate.

setX

public void setX(int x)
Sets the upper left coordinate.
Parameters:
x - The x-coordinate this counter will use.

getY

public int getY()
Returns the base y-coordinate. The base coordinate is the topmost y-coordinate of the counter.
Returns:
Base y-coordinate.

setY

public void setY(int y)
Sets the upper left coordinate.
Parameters:
y - The y-coordinate this counter will use.

getWidth

public int getWidth()
Returns the width of this counter.
Returns:
Width of this counter.

getHeight

public int getHeight()
Returns the height of this counter.
Returns:
Height of this counter.

GF4J 0.9.4 Beta