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

2018/1/27

If (Greenfoot.isKeyDown("space")). Update the images

frequency frequency

2018/1/27

#
Hello, I want to create a new easier game called "tap me fast". I want for now to make the user press space as fast as possible.While doing that 2 images will be used. If he pressed space PRESSED.png will show up in the world,if he stoped pressing space or lift his finger to press it again UNPRESSED.png will be shown. Take a look https://www.youtube.com/watch?v=fSp7DeQ4IO0&t=1s SCENARIO http://www.greenfoot.org/scenarios/20749
xbLank xbLank

2018/1/27

#
Use Greenfoot.getKey() instead.
Vercility Vercility

2018/1/27

#
Where is the question?
frequency frequency

2018/1/27

#
Change the from one image to an other when i key is pressed
xbLank xbLank

2018/1/27

#
if(Greenfoot.getKey().equals("space")
    this.setImage("pressed.png");
else this.setImage("unpressed.png");
something like this^^
frequency frequency

2018/1/27

#
void addObject()
    {
     if(Greenfoot.getKey().equals("space"))
        {
            this.setImage("pressed.png");
        }
            else {
            
                this.setImage("unpressed.png");
                  }
        }
    }
Cant get it to work.This is placed on WORLD!
frequency frequency

2018/1/27

#
https://www.youtube.com/watch?v=fSp7DeQ4IO0 I want to create this!
Vercility Vercility

2018/1/27

#
why is the method called addObject .. (Please god I hope this doesnt somehow overload greenfoot.addObject ) You also put that in act() .. ? Else it wont be executed
frequency frequency

2018/1/27

#
I will take a look,and see! Thank you!
frequency frequency

2018/1/27

#
I will make a new topic,since i moved on a bit!
You need to login to post a reply.