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

2014/3/19

Mouseclickmessage

Tapato Tapato

2014/3/19

#
Hey, I'm attempting to make a video game and I need a code wich indicates the coordonate of the mouse with a click on the game ( so we click and the coordonates appears with a little message ) How I have to code this ? Thanks
danpost danpost

2014/3/19

#
Please review the documentation of the MouseInfo class via the 'Documentation' link above.
Tapato Tapato

2014/3/19

#
Thanks, Of course I read it but I have always the same problem, I don't know how to start. I tried and looked every scenarios with mouse but I didn't find ....
danpost danpost

2014/3/19

#
To use the methods of a class you need to create an object of that class. So, first create a MouseInfo object:
MouseInfo mouse = Greenfoot.getMouseInfo();
Then, use the methods on 'mouse' to get the information you want.
Tapato Tapato

2014/3/20

#
Thanks
Tapato Tapato

2014/3/20

#
I found the mouse info and the coordonates How I have to code for a message, wich indicates the position of the mouse when I click, appears ?
danpost danpost

2014/3/20

#
Use a basic Actor object and give it the image you require. You can create the image with the text of wanted font size and colors using the proper GreenfootImage constructor call.
Tapato Tapato

2014/3/22

#
But can't we put a method in subclass World wich can make a ''Method call'' when you click on the right of the mouse ?
danpost danpost

2014/3/22

#
Tapato wrote...
But can't we put a method in subclass World wich can make a ''Method call'' when you click on the right of the mouse ?
Yes, but this
danpost wrote...
Use a basic Actor object and give it the image you require. You can create the image with the text of wanted font size and colors using the proper GreenfootImage constructor call.
is what is to happen within that method (maybe 'create a basic Actor object' would have been less confusing than 'use a basic Actor object').
You need to login to post a reply.