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.
private/public static int score = 0;
private/public static int score; //in the constructor score = 0;
public X()
{
//...
}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);
}
}