I have a static int variable for my score so i can go up levels but now when i die and go onto the lost screen and reset and start over the score stays the same as when i died is any one able to help me it would be greatly appreciated.


1 | private / public static int score = 0 ; |
1 2 3 | private / public static int score; //in the constructor score = 0 ; |
1 2 3 4 | public X() { //... } |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) // i need to make an level varible /** * Write a description of class Space here. * * @author (your name) * @version (a version number or a date) */ public class Level1 extends Start { Counter counter = new Counter(); // static int score; //int score1; public void act() { } /** * Constructor for objects of class Space. * */ public Level1() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super (); prepare(); score = 0 ; reset(); } public Counter getCounter() { return counter; } public void reset() { score = 0 ; } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ private void prepare() { Rocket rocket = new Rocket(); addObject(rocket, 14 , 243 ); Rock rock = new Rock(); addObject(rock, 673 , 344 ); Rock rock2 = new Rock(); addObject(rock2, 638 , 55 ); Rock rock3 = new Rock(); addObject(rock3, 672 , 265 ); Rock rock4 = new Rock(); addObject(rock4, 363 , 225 ); Rock rock5 = new Rock(); addObject(rock5, 697 , 98 ); Rock rock6 = new Rock(); addObject(rock6, 793 , 269 ); Rock rock7 = new Rock(); addObject(rock7, 832 , 425 ); Rock rock8 = new Rock(); addObject(rock8, 468 , 348 ); Rock rock9 = new Rock(); addObject(rock9, 523 , 202 ); Rock rock10 = new Rock(); addObject(rock10, 382 , 69 ); Rock rock11 = new Rock(); addObject(rock11, 380 , 422 ); Rock rock12 = new Rock(); addObject(rock12, 477 , 115 ); Rock rock13 = new Rock(); addObject(rock13, 477 , 115 ); Rock rock14 = new Rock(); addObject(rock14, 301 , 90 ); Spawn spawn = new Spawn(); addObject(spawn, 978 , 486 ); addObject(counter, 47 , 61 ); } } |