hmmm well its a secret =P ........ just kidding ill post the code here for u 2 see
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
import java.awt.Font;
/**
* Counter that displays a number.
*
* @author Michael Kolling
* @version 1.0.1
*/
public class Counter extends Actor
{
private int value = 0;
private int target = 0;
private String text;
private int stringLength;
public Counter()
{
this("");
}
public Counter(String prefix)
{
text = prefix;
stringLength = (text.length() + 2) * 16;
setImage(new GreenfootImage(stringLength, 24));
GreenfootImage image = getImage();
Font font = image.getFont();
image.setFont(font.deriveFont(24.0F)); // use larger font
updateImage();
}
public void act() {
if(value < target) {
value++;
updateImage();
}
else if(value > target) {
value--;
updateImage();
}
}
public void add(int score)
{
target += score;
}
public void subtract(int score)
{
target -= score;
}
public int getValue()
{
return value;
}
/**
* Make the image
*/
private void updateImage()
{
GreenfootImage image = getImage();
image.clear();
image.drawString(text + value, 1, 18);
}
}
hmmm well its a secret =P ........ just kidding ill post the code here for u 2 see
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
import java.awt.Font;
/**
* Counter that displays a number.
*
* @author Michael Kolling
* @version 1.0.1
*/
public class Counter extends Actor
{
private int value = 0;
private int target = 0;
private String text;
private int stringLength;
public Counter()
{
this("");
}
public Counter(String prefix)
{
text = prefix;
stringLength = (text.length() + 2) * 16;
setImage(new GreenfootImage(stringLength, 24));
GreenfootImage image = getImage();
Font font = image.getFont();
image.setFont(font.deriveFont(24.0F)); // use larger font
updateImage();
}
public void act() {
if(value < target) {
value++;
updateImage();
}
else if(value > target) {
value--;
updateImage();
}
}
public void add(int score)
{
target += score;
}
public void subtract(int score)
{
target -= score;
}
public int getValue()
{
return value;
}
/**
* Make the image
*/
private void updateImage()
{
GreenfootImage image = getImage();
image.clear();
image.drawString(text + value, 1, 18);
}
}
2012/1/3
Pong
2012/1/3
Pong
2012/1/3
FireCardemo
2012/1/3
FireCardemo
2012/1/2
Guns vs Zombies
2012/1/2
Guns vs Zombies
2011/12/30
YUM!
2011/12/30
YUM!
2011/12/30
YUM!