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

2017/8/4

Game Over/Reset Screen struggles

tMsuperhero tMsuperhero

2017/8/4

#
Hello, I'm currently working on a game in which two people fight eachother. I want to make it so, that when my actor (MAND1) has been hit, a reset screen follows. The problems I'm having are whenever I hit the 'run' button, the resetScreen appears instantly, but I only want it to appear, when an actor has intersected with 'Ildkugle'. I have tried the following codes: This applies to the MAND1 Actor
    public void hitIldkugle()
    {
        Actor ildkugle = getOneIntersectingObject(Ildkugle.class);
        if(ildkugle != null)
        {
            World myWorld = getWorld();
            myWorld.removeObject(this);
        }
        {
            Greenfoot.setWorld(new resetScreen());
        }

    }    
}
This applies to the resetScreen world class
    public void act()
    {
        if(Greenfoot.isKeyDown("enter"))
        Greenfoot.setWorld(new MyWorld());
    }
danpost danpost

2017/8/4

#
Currently, the code to execute when intersecting 'ildkugle' is between lines 5 and 8. If you want the resetScreen to activate at that time, then that is where you need to set that world at..
tMsuperhero tMsuperhero

2017/8/4

#
oh.. obviously... thanks!
You need to login to post a reply.