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

danpost's Comments

Back to danpost's profile

The 'NullPointerException' is one of the most common run-time error messages. It is telling you that you are trying to do something to nothing as if it were something. That kind of sounds strange, I guess, but in your case, after the fly is removed, it no longer has a world; therefore 'getWorld()' in the next line becomes 'null'; hence, the 'NullPointerException'.
The terminal window is there to assist you. You were getting a message that started with: Line 1: java.lang.NullPointerException Line 2: at Fly.die(Fly.java:135) Line 3: at Fly.act(Fly.java:32) Line 1 tells you why the scenario stopped (the error type) Line 2: tells you where in your code the error occurred (line 135 of the Fly class in the die() method) Line 3: may show where the method was called from (line 32 of the Fly class in the act() method) Lines 2 will not always be immediately after the error type, but will be somewhere in the message (it will be the first one that is recognizably in your scenario)
Reverse the last two lines of code in the Fly class (add the burger before removing fly).
I'll download and take a look.
I have to keep clicking on the 'Run' button 'cause it keeps stopping.
OH, I need glasses (and I have them on!) :/ I saw 1,138 kb (that is a 'one' followed by a 'comma', not a 'period').
You are right, NOW I am seeing 1.1mb (I do not know where I saw the 1.1kb at, but I looked twice at it, to be sure!).
Just read up on working with BufferedImage and was wondering if you went that route. Well, you did not; you went the way I probably would have coded it. In fact it is very similar to code I wrote on an in-house project. Oh, BTW, the background file size is 1.1 kb (not mb).
What is happening is this, you have in the Bullet act() method two method calls, each which could remove the bullet from the world. If the first one removes the bullet, then there is no world to check location of it, or any other object. Probably best to check collision of bullet with invader in the invader class, and just check for worldedge in the bullet class.