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

2014/11/4

Mouse movement

Judscar922 Judscar922

2014/11/4

#
How can I get an actor to move with my mouse?
Alwin_Gerrits Alwin_Gerrits

2014/11/4

#
Specify your idea please, Does it have to go after the mouse or should it be exactly where the mouse is at all times?
Judscar922 Judscar922

2014/11/4

#
The latter. I'm trying to build a first-person shooter, but I need the crosshairs to follow the mouse.
danpost danpost

2014/11/4

#
There are two methods in the MouseInfo class that detect mouse movement -- the 'mouseMoved' and the 'mouseDragged' methods. When either becomes true, get a MouseInfo object and make sure it is not a 'null' value before getting its world coordinate values to set your actor at.
Alwin_Gerrits Alwin_Gerrits

2014/11/4

#
If you want some commands follow the link here: link and search on the greenfoot api for 'mouse'. That should give an idea of all the methods there are which do something with the mouse.
danpost danpost

2014/11/4

#
You can search through the methods found here for methods that return various states of the mouse and also to get a MouseInfo object. And, you can go here for the MousInfo class API to see what methods are available to use on a MouseInfo object..
You need to login to post a reply.