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

2014/6/27

IsKeyDown doesnt work!?

Hutanoi Hutanoi

2014/6/27

#
Hey guys, i got an problem with starting my scenario. I want to start it if the key "p" is pressed. The scenario was already started by the world, which also created the Object of the Class "Startscreen". This is my code from the "Startscreen"-Class:

public void act() 
    {
        if (Greenfoot.isKeyDown("p") == true)
        {
            startSpiel();
        }
    }  

    public void startSpiel()
    {
        
        

        getWorld().addObject(((Welt)getWorld()).raumschiff, 500, 300);

        getWorld().addObject(((Welt)getWorld()).x, 950, 300); 

        getWorld().addObject(((Welt)getWorld()).raumschiff, 500, 300);

        ((Welt)getWorld()).anzeigeZ.setText("Spielzeit:");
        ((Welt)getWorld()).anzeigeP.setText("Punkte:");
        ((Welt)getWorld()).anzeigeM.setText("Munition:");

        getWorld().addObject(((Welt)getWorld()).anzeigeZ, 138, 560);
        getWorld().addObject(((Welt)getWorld()).anzeigeP, 111, 530);
        getWorld().addObject(((Welt)getWorld()).anzeigeM, 130, 500);

             getWorld().removeObject(this);
        
    }

I cant start the scenario with pressing "p" ... Any ideas?
danpost danpost

2014/6/27

#
Please show the code for your Welt class.
You need to login to post a reply.