This site requires JavaScript, please enable it in your browser!
Greenfoot back
trias95
trias95 wrote ...

2014/3/30

Passing a score from one world to another?

1
2
3
4
5
6
trias95 trias95

2014/3/30

#
when i die i just get the null pointer exception
trias95 trias95

2014/3/30

#
java.lang.NullPointerException at greenfoot.World.addObject(World.java:392) at GameOver.prepare(GameOver.java:68) at GameOver.<init>(GameOver.java:29) at Zombie.act(Zombie.java:43) at greenfoot.core.Simulation.actActor(Simulation.java:568) at greenfoot.core.Simulation.runOneLoop(Simulation.java:526) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205)
danpost danpost

2014/3/30

#
What is showing on the terminal? or did you even add the line like I asked?
trias95 trias95

2014/3/30

#
Yes the line is in there but the terminal shows nothing. terminal and code
danpost danpost

2014/3/30

#
With the terminal, go to the menubar and select 'Options>Clear' and close out the terminal. Then compile, run and die, report back again.
danpost danpost

2014/3/30

#
NOTE: change last post replacing 'reset' with 'compile'.
trias95 trias95

2014/3/30

#
again its completely blank :/
trias95 trias95

2014/3/30

#
Would it help if i uploaded the game and then you can download it and see just whats going on?
danpost danpost

2014/3/30

#
Sorry my fault. Move the System.out.println statement up one line (to before the 'prepare' call).
trias95 trias95

2014/3/30

#
thast got it :) "Counter object is null: false
danpost danpost

2014/3/30

#
'false' O_O Wow. Okay. Move it to the first line in the prepare method and try again.
danpost danpost

2014/3/30

#
NVM. Move 'this.counter = counter' to before the 'prepare' call in the constructor and remove the System.out.println statement.
trias95 trias95

2014/3/30

#
oh. okay so now the game over screen works? 0.0 but now the counter isnt there at all as in not even displaying a 0
trias95 trias95

2014/3/30

#
private void prepare()
    {
        System.out.println("Counter object is null: "+(counter == null));
        
            
        TryAgain tryagain = new TryAgain();
        addObject(tryagain, 681, 551);
        laughingSkull laughingskull = new laughingSkull();
        addObject(laughingskull, 683, 119);
        
        addObject(counter, 462, 575);
        counter.setLocation(454, 568);
        ;
    }
Not sure if this helps but both the counter, laughingSkull and TryAgain classes do not appear on the world either
danpost danpost

2014/3/30

#
Maybe it might be better if you just upload it so I can take a quick look see. Oh, just click on the scenario. (and remove the System.out.println)
There are more replies on the next page.
1
2
3
4
5
6