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

2017/12/9

Transform isKeyDown to mousePressed

blblewah blblewah

2017/12/9

#
Hey, i have a situation. Right now i use isKeyDown to move some actor. The logic is i have Stage class and it have many subclasses. In Stage class contain a method (lets call it key) that contain isKeyDown commad. And in Stage subclasses i will call Key method(so it doesnt need many source code because the sc is the same among the subclasses). The problem is i want to change isKeyDown to mousePressed trough button actor. So when i press the button actor it will do the same task like isKeyDown. How can it work? i already use many sc but it doesnt work. Thank you :)
Super_Hippo Super_Hippo

2017/12/9

#
Your condition could be that either the key or the mouse is pressed. Note that pressing the mouse is a little bit different. There is no "isMouseKeyDown" method. You can only check when the mouse changes from one state to another. So when it is pressed and when it is released. But you could check if a mouse press is detected on the button and then check the location of the mouse (if it is still over the button) and if the button was released. If one of that happened, "isMouseKeyDown" would be false.
You need to login to post a reply.