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

2020/3/4

if key down

TakedaYeet TakedaYeet

2020/3/4

#
im making a simple game where once you've killed all people, and pressed enter, you go to the next level here is the code
if(isTouching(human1.class))
        {
            if (getWorld() instanceof level1)
            {
                removeTouching(human1.class);
                bumpCounter(1);
                Greenfoot.playSound ("scream1.1.mp3");              
                if (getWorld().getObjects(human1.class).isEmpty() )
                {
                    canMove = false;
                    if (Greenfoot.isKeyDown("e"))
                    {
                        victory victory = new victory();
                        World world = getWorld(); 
                        world.addObject(victory, 550, 200);
                        bumpCounter(1);
                        Greenfoot.delay(200);
                        level2 l2 = new level2();
                        Greenfoot.setWorld(l2);
                    }
                }
}
my problem is that greenfoot doesn't realise that enter is being pressed and doesn't do anything, the only button greenfoot detect for some reason is w, anything else and it doesn't read it, please help if you can
danpost danpost

2020/3/4

#
Lines 11 thru 20 should not be inside the if (isTouching(human1.class)) block.
TakedaYeet TakedaYeet

2020/3/9

#
thanks
You need to login to post a reply.