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

2011/4/16

Mouse Wheel and Image

PiRocks PiRocks

2011/4/16

#
How do you detect when someone is rolling the mouse button in Greenfoot? I can't find any documented support for it and my scenario is complicated enough without dealing with the problems of custom mouse control. Also, how do you find the proper Component for changing the mouse's image with (and if worse comes to worse, implementing a custom mouse system with)?
architsch architsch

2011/4/17

#
First, import the package "java.awt.event.*". Make an inner class that implements the interface, "MouseWheelListener." Inside that inner class, create a method that has the title, "public void mouseWheelMoved(MouseWheelEvent e)" This method will be executed whenever you roll your mouse wheel. "e" is the variable that stores the information of your current mouse wheel movement.
Builderboy2005 Builderboy2005

2011/4/18

#
I tried using the technique you suggested and got no results when I implemented it, should the class be implemented directly into the world code? Implemented as a seperate class file? Does it need to extend or implement anything else important?
Builderboy2005 Builderboy2005

2011/4/18

#
Ah, fixed it. I needed to add it into the world panel by using: WorldHandler.getInstance().getWorldCanvas().addMouseWheelListener(myScrollingListener);
You need to login to post a reply.