The easiest way is probably to remove your boolean 'NewWorld' altogether and change your YesNewWorld method to:
public void YesNewWorld() { Greenfoot.setWorld(new Swiat()); }
public void YesNewWorld() { Greenfoot.setWorld(new Swiat()); }
public void YesNewWorld() { Swiat world = new Swiat(); world.getCounter().setValue(getCounter().getValue()); world.getLives().setValue(getLives().getValue()); Greenfoot.setWorld(world); }
Swiat world = new Swiat(); int a = getCounter().getValue(); world.getCounter().setValue(a); int b = getLives().getValue(); world.getLives().setValue(b); Greenfoot.setWorld(world);
public void setValue(int a){ totalCount = a; }
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 int totalCount; public Counter() { setImage(new GreenfootImage("SCORE: " +totalCount , 30, Color.BLACK, Color.WHITE)); } /** * Increase the total amount displayed on the counter, by a given amount. */ public void bumpCount(int amount) { totalCount += amount; setImage(new GreenfootImage("SCORE: " + totalCount, 30, Color.BLACK, Color.WHITE)); } public int getValue(){ return totalCount; } public void setValue(int a){ totalCount = a; } }
public void setValue(int a) { totalCount = a; bumpCount(0); }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class szanse here. * * @author (your name) * @version (a version number or a date) */ public class szanse extends Actor { boolean NewGameStarted; public int Lifes; public szanse() { if(NewGameStarted = true) { Lifes = 3; } } public void LifeCounter() { if(Lifes==3) { setImage("3szanse (Custom).jpg"); } if(Lifes==2) { setImage("2szanse (Custom).jpg"); } if(Lifes==1) { setImage("1szanse (Custom).jpg"); } if(Lifes==0) { Swiat swiatWorld = (Swiat) getWorld(); NewGameStarted = true; swiatWorld.YesNewWorld(); } } public int getValue(){ return Lifes; } public void Subtraction(int HowMany) { Lifes = Lifes - HowMany; } public void setValue(int b){ Lifes = b; NewGameStarted = false ; }}
public void checkpileczka() { Actor S = getOneIntersectingObject(pileczka.class); if (S != null) { if (((Losowanko) getWorld().getObjects(Losowanko.class).get(0)).getNumber()==0) { ObjectHit(); getWorld().removeObject(S); getWorld().removeObject(this); if(getWorld().getObjects(pileczka.class).size() == 0) { Swiat swiatWorld = (Swiat) getWorld(); swiatWorld.Done(); } else {} } else { ObjectMissed(); getWorld().removeObject(S); getWorld().removeObject(this); } } }
if (Lifes == 0) { Greenfoot.setWorld(new Swiat()); }
if(getWorld().getObjects(pileczka.class).size() == 0) { Swiat swiatWorld = (Swiat) getWorld(); swiatWorld.Done(); } else {}