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

2019/3/19

How to make an actor appear after something happens?

Poseidon420 Poseidon420

2019/3/19

#
I'm trying to make a game and i want a gameover image to come up when i die but it keeps having a error. Any help?
danpost danpost

2019/3/19

#
Poseidon420 wrote...
I'm trying to make a game and i want a gameover image to come up when i die but it keeps having a error. Any help?
Cannot help with code that cannot be seen or error message that is unknown.
Poseidon420 Poseidon420

2019/3/19

#
move(speed);
        Actor t;
        t = getOneObjectAtOffset(0, 0, Plane.class);
        if(isAtEdge())
        {
            g = new GameOver();
            getWorld().removeObject(this);
            getWorld().addObject(g, 375, 500);
        }
        if(t!=null)
        {
            g = new GameOver();
            World w = getWorld();
            w.removeObject(this);
            w.removeObject(t);
            getWorld().addObject(g, 375, 500);
            Greenfoot.stop();
        }
is there anything wrong with that?
danpost danpost

2019/3/19

#
Poseidon420 wrote...
<< Code Omitted >> is there anything wrong with that?
Here is one thing. Line 8 calls getWorld after line 7 removes the actor from the world. It is not so much that you call it as it is that it then returns a null value and you "blindly" call a method on that value.
Poseidon420 Poseidon420

2019/3/19

#
Thank you dan it worked now
You need to login to post a reply.