When I switch levels by score goes to 0 again. How can I continue my score from previous level. I'm using the counter sub class. Can someone help me right a code that would allow to continue score.
MyWorld newWorld = new MyWorld(); Counter newCounter = (Counter) newWorld.getObjects(Counter.class).get(0); Counter oldCounter = (Counter) getWorld().getObjects(Counter.class).get(0); newCounter.setValue(oldCounter.getValue()); Greenfoot.setWorld(newWorld);
MyWorld newWorld = new MyWorld(); Counter newCounter = (Counter) newWorld.getObjects(Counter.class).get(0); Counter oldCounter = (Counter) getWorld().getObjects(Counter.class).get(0); newCounter.setValue(oldCounter.getValue()); Greenfoot.setWorld(newWorld);