-6

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 ?

1
  • 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. Commented May 1, 2015 at 10:14

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
Sorry, I may have missed your deadline. The first link I posted references this sample code: docs.oracle.com/javase/tutorial/uiswing/examples/events/… docs.oracle.com/javase/tutorial/uiswing/examples/events/… - these should give you everything you need.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.