I am making the GUI of yugioh game ana I want to summon monster with left click and set monster with right click how could I make that in a simple way ?
Asked
Active
Viewed 237 times
-6
-
What technology are you using to make your UI? Is it browser based? Javascript? Swing? There are a lot of choices, and this will hugely impact how best to handle user interaction. – hugh May 01 '15 at 10:14
1 Answers
0
If you're using Swing, this is probably what you'll need: Mouse Listeners Once you've got your Swing elements on the page, take the one you want to respond to mouse events (I imagine that's play area?), and write a MouseAdapter class which handles the input to call your game logic for "set monster" and "summon monster". This answer then explains how to distinguish left- and right-clicks.
Please be aware though, there's a huge amount of work you'll need to do before you should be worrying about handling user input. Prototyping is sensible, but it's a very good idea to design your data model and game logic before you start writing the UI.
-
I have finished from the game logic and I have to submit the last milestone which is about the UI today before 23:00 so could you give me a sample of the code please and thank you in advance – mohamed magdy May 01 '15 at 13:19
-
Sorry, I may have missed your deadline. The first link I posted references this sample code: https://docs.oracle.com/javase/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/BlankArea.java https://docs.oracle.com/javase/tutorial/uiswing/examples/events/MouseEventDemoProject/src/events/MouseEventDemo.java - these should give you everything you need. – hugh May 02 '15 at 09:24