Java Reference
In-Depth Information
Figure 12. WakeupOnBehaviorPost event and usage
WakeupOnBehaviorPost (Behavior behavior, int postId)
// Constructor for a new WakeupOnBehaviorPost criterion.
Behavior getBehavior()
// Method for returning the behavior for an object
int getPostId()
// Retrieves the postId
Behavior getTriggeringBehavior()
// Returns the behavior that triggered the wakeup.
int getTriggeringPostId()
// Returns the postId that caused the behavior to wakeup.
Figure 13. First code segment of PostBehavior.java
1.
public class PostBehaviour extends Applet
2.
{
3.
public class MoveRight extends Behavior
4.
{
5.
private TransformGroup targetTG;
6.
private Transform3D trans = new Transform3D();
7.
private WakeupCriterion pairPostCondition;
8.
private WakeupCriterion wakeupNextFrame;
9.
private WakeupCriterion AWTEventCondition;
10.
private double transX;
11.
12.
MoveRight(TransformGroup targetTG)
13.
{
14.
this.targetTG = targetTG;
15.
AWTEventCondition = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
16.
wakeupNextFrame = new WakeupOnElapsedFrames(0);
17.
}
18.
19.
public void setBehaviorObjectPartner(Behavior behaviorObject)
20.
{
21.
pairPostCondition = new WakeupOnBehaviorPost(behaviorObject, 2);
22.
}
23.
24.
public void initialize()
25.
{
26.
this.wakeupOn(AWTEventCondition);
27.
transX = 0.0;
28.
}
29.
Search WWH ::




Custom Search