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

2012/8/3

Problem with getKey() in MouseInfo

SPower SPower

2012/8/3

#
Hi all, I'm trying to improve the drawing of my Paintshop scenario, but I'm having trouble with the getKey() method. It seems that when you hold down the left button of the mouse (getKey should return 1 all the time), it sometimes returns 0 instead of 1. Is this just a bug, or am I probably doing something wrong?
iau iau

2012/8/3

#
getKey() is not quite what you want. getKey() will only return a key once for each time it is pressed, so if you press the left-arrow key and then call getKey twice, it will return first "left" and then null. If you want to see if the left-arrow key is being held down, use isKeyDown("left") which will return true if the key is currently down, and false otherwise.
SPower SPower

2012/8/3

#
BIG OOPS! Your answer is right, but I actually have problems with getButton. Sorry for the big mistake.
You need to login to post a reply.