Hi again, I want to pass a boolean from 'Bij' class to the 'Tijd' class from Actor.
I will explain the scenario. There is a 'Bij' and he gets points while playing. If the timer is on 0, I want to check wether the Bij has enough points to go to the next level, so I need the boolean if there are enough points from the class 'Bij'
I have this, but it don't work. I get the error NullpointerException...
In class Tijd
In class Bij
Can somebody help me?
Bij koppelingBij; public void checkEind(){ if (resterendeTijd == 0) { if (koppelingBij.aantalPunten == false){ World s = new Level1_Verlies(); // creates an AllstarsWorld object and names it 'a' s.addObject(new Bij_1(), 500, 500); Greenfoot.setWorld(s); // sets the new AllstarsWorld ('a') active World wereld = getWorld(); // as a World object, members of MyWorld are inaccessible Level1 level1 = (Level1) wereld; // the world cast as a MyWorld object level1.achtergrondMuziek.stop(); // stopping the music } if (koppelingBij.aantalPunten == true){ World s = new Level2(); // creates an AllstarsWorld object and names it 'a' s.addObject(new Bij_2(), 500, 500); Greenfoot.setWorld(s); // sets the new AllstarsWorld ('a') active World wereld = getWorld(); // as a World object, members of MyWorld are inaccessible Level1 level1 = (Level1) wereld; // the world cast as a MyWorld object level1.achtergrondMuziek.stop(); // stopping the music } } } public void stelBijIn (Bij kb) { koppelingBij = kb; }
public boolean aantalPunten = false; public boolean aantalPunten () { if (punten <= 9) return true; else return false; }