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

2013/9/16

Timer

RedFox92 RedFox92

2013/9/16

#
Can you put a timer on a key Ive put a burst of speed in my actor (But if they hold it in the game will be no fun
sametguzelgun sametguzelgun

2013/9/16

#
import greenfoot.*;
public class Timer extends Actor
{
    private int time = 200;
    private boolean start = false;
    public void timer()
    {
        time--;
    }
    public void act()
    {
        if(Greenfoot.isKeyDown("space"))
        {
            start = true;
        }
        if(start == true)
        {
            timer();
        }
        if(time == 0)
        {
            // put your code here
        }
    }
}
like? Note: Edited.
You need to login to post a reply.