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

2011/8/5

How to practice Greenfoot API

yemengreenfoot yemengreenfoot

2011/8/5

#
How can i use..... isKeyDown method. Could someone give me an example to use isKeyDown method. Is there a way to practice Greenfoot API ? Most of the time i got errors.
Advenging Advenging

2011/8/5

#
This scenario has help me too understand of a lot of methods. http://greenfootgallery.org/scenarios/12
private void checkKeys()
    {
        if (Greenfoot.isKeyDown("left") )
        {
            setImage("pengu-left.png");
            moveLeft();
        }
        if (Greenfoot.isKeyDown("right") )
        {
            setImage("pengu-right.png");
            moveRight();
        }
        if (Greenfoot.isKeyDown("space") )
        {
            if (onGround())
                jump();
        }
    }    
You can find this code in the Actor Pengu. Have a nice day. Advenging
yemengreenfoot yemengreenfoot

2011/8/7

#
Thank you. It works.
You need to login to post a reply.