danpost wrote...
Ok. Now remove lines 11 and 22 from the Start class and show your Counter class code.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Counter here. * * @author (your name) * @version (a version number or a date) */ public class Counter extends Actor { private static int score; public static int level; /** * 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, 24 , Color.RED, Color.BLACK)); // this sets the image to say Score but then add what ever the score is so it may look like this Score:10 and at the start it looks like Score:0 } public void addScore() { score++; // this code adds a score of 1 each time an Rock is killed if (score == 3 // need to make a level varible ){ Greenfoot.setWorld( new L2()); level= 1 ; score= 4 ; // This code changes the back ground to level 2 when 3 points are scored } if (score == 20 ){ Greenfoot.setWorld( new L3()); level = 2 ; score= 21 ; //This code changes the back ground to level 3 when 20 points are scored } if (score == 30 ){ Greenfoot.setWorld( new Finished()); score= 0 ; //This code changes the back ground to the finished screen when 30 points are scored } } public void reset() { score = 0 ; } } |
1 2 3 4 | public Counter() { update(); } |