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

2014/2/1

how to create a mouse game

Mint_Green Mint_Green

2014/2/1

#
how do I make a shooting game work with the mouse, like when you click it shoots. Please help thanks! mint_green
Mint_Green Mint_Green

2014/2/1

#
by the way this is in greenfoot all the tutorials I checked use keys on the arrows keys.
danpost danpost

2014/2/1

#
Simply put, to have shots fired at the mouse when clicked, you start with:
1
2
3
if (Greenfoot.mouseClicked(null))
{
    MouseInfo mouse = Greenfoot.getMouseInfo();
followed by MouseInfo methods being executed on the MouseInfo object that the field 'mouse' refers to. Please see the MouseInfo class documentation for the methods that you can use on 'mouse'.
Mint_Green Mint_Green

2014/2/1

#
thank you.
jimboweb jimboweb

2014/2/3

#
If you want to know more about using the mouse I have an example with explanation here: http://mrstewartslessons.com/move_actor_with_mouse.html and I have a video lesson about it here: http://www.youtube.com/watch?v=HCl_XGWYYmc
csr1010 csr1010

2014/2/3

#
danpost was right on the money, this is tricky to figure out.
danpost danpost

2014/2/3

#
It is really not that tricky. Once you get the location of the mouse with the MouseInfo methods 'gexX' and 'getY', you can use the Actor class 'turnTowards' method on the shot to set its direction of movement.
You need to login to post a reply.