Java Reference
In-Depth Information
Figure 8. WakeupOnAWTEvent and usage
WakeupOnAWTEvent(int AWTId)
// Constructor for a new WakeupOnAWTEvent object.
// AWTId is the AWT ids that we would like to intercept. Common values are:
WakeupOnAWTEvent(long eventMask)
// Constructor for a new WakeupOnAWTEvent object using EVENT_MASK values in
// logical or format. Common values are:
AWTEvent[] getAWTEvent()
// Method for retrieving the array of consecutive AWT event triggering the wakeup.
posted events
Other than user and external events such as the pressing of keys or buttons or mouse move-
ment, it is also possible for a behavior to post an event to the system. This is the same as
having an external stimulus and will result in a wakeup trigger, perhaps resulting in the
execution of the appropriate prosessStimulus method and leading to a change in the 3D
world being rendered.
The mechanism for achieving this is through the setting of the WakeupOnBehaviorPost
condition together with an integer postId for identification purposes. Figure 12 shows the
usage of this mechanism as well as some accompanying methods for setting and identify-
ing the behavior and postId causing the wakeup.
The ability for posting events is very useful for developing codes involving the movement
of different objects or complicated behavior. It allows for different behaviors to coordinate
with one another after the virtual world has gone through some identifiable important
changes. For instance, in a simple application involving the opening and closing of a door,
it may be easier to develop two different individual behaviors for the two different actions,
and have one behavior posting a message to wakeup the other behavior if a door closing
operation is to follow a door closing one.
The code segment in Figures 13 to 15 illustrate the use of WakeupOnBehaviorPost for
shifting an object to the right if a key is pressed, to the left when the next key is pressed,
Search WWH ::

Custom Search