I am attempting to create a game with a small team of friends. I had the idea of taking advantage of Event-Driven programming to deal with User Interaction, and I wanted some words-of-wisdom from some of the people on this messageboard.
First of all, we would be required to create a custom Event class and a custom EventListener class. The EventListener would probably be straightforward, but I'm not familiar with creating custom Events. Does anyone have any suggested reading material?
Our current design incorporates an Android GUI, a Director class, the Event class, and a handful of sprites with different states. I would like an opinion on our design.
The flow goes like this:
1. The Director class has an EventListener attached to it.
2. The user does something on the GUI. A custom Event is created with some sort of payload explaining what the Event was.
3. The Event is sent to the Director, which hears the Event, changes the states of the sprites in some way, and notifies the GUI that the changes have been made (somehow).
4. The GUI adjusts the images and information on the screen based on the new states of the sprites.
Other than opinions on the design, how would we send the Director an Event in such a way that the EventListener would react to it? My main experience with Event-Driven programming is using Swing, but those Events are already created somehow and received by the component with the listener attached. I understand how to handle Events, just not how to create and send them.
Re: Custom Events
Look at the Java SE doc for the different Events it has and model yours after them.
just not how to create
Did you ask Google: create custom java event
Also see the Observable class.