For the final part of my game, i need a counter that always goes up until I die so kinda like a timer (000000) goes up 100 points a second.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | int score = 0 ; /** * Act - do whatever the Counter wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { setImage( new GreenfootImage( "Score : " + score, 60 , Color.GREEN, Color.YELLOW)); addScore(); } public void addScore() { score++; } |
1 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) |
1 | import java.awt.Color; |
1 | elapsedTime = ( int ) (System.currentTimeMillis() - startTime); |