net.nexttext.behaviour
Interface Action

All Known Subinterfaces:
TargetingAction
All Known Implementing Classes:
AbstractAction, ApplyToGlyph, Approach, Blow, Bounce, Chain, ChaosPull, Colorize, Condition, CustomAction, DebugLog, Delay, Descend, DForm, DoNothing, Explode, FadeTo, Follow, FollowSibling, Gravity, IsInside, Kern, Kill, Move, MoveBy, MoveTo, Multiplexer, OnButtonDepressed, OnCollision, OnDrag, OnMouseDepressed, OnMouseIn, OnMouseInApplet, OnMouseOut, OnMouseOutApplet, OnMouseOver, OnMouseOverApplet, OnMousePressed, OnMousePressedOver, OnMouseReleased, OnMouseReleasedOver, PhysicsAction, Pull, Push, RandomMotion, Reform, Repeat, Scale, Selector, Spin, StayInside, StayInWindow, Stop, Throb, Timer, Tracker

public interface Action

Actions are building blocks used to create behaviours.

Some Actions modify TextObjects in simple ways, typically incrementally over many frames. Some Actions provide controls for invoking other Actions and do not themselves modify TextObjects directly. Actions are plugged together and wrapped into a Behaviour, which is then used by the Book.

The way Actions are plugged together, and the fact that they are often interactive, makes it very difficult to predict when or if an Action will be called. This unpredictability causes difficulty with two aspects of an Action's functioning: the way it stores state in order to maninpulate a TextObject continuously across frames; and knowing if and when an action will be done with a specific TextObject. This interface defines two mechanisms to help with this problem: a method complete(TextObject) which can be called to let an Action know that it can clean up state, because it will not be called with that TextObject again; and boolean fields in ActionResult to indicate if an Action is complete, or can be expected to complete. An Action may be called again after completeness is indicated through these mechanisms, which is interpreted as the Action "starting again".


Nested Class Summary
static class Action.ActionResult
          Used to communicate results of Action.behave().
 
Method Summary
 Action.ActionResult behave(TextObject to)
          Performs the action on a TextObject.
 Action.ActionResult behave(TextObject[] to)
          Performs the action on a set of TextObjects
 Action.ActionResult behave(TextObject toA, TextObject toB)
          Performs the action on a pair of TextObjects
 void complete(TextObject to)
          Inform an Action that it won't need to work on this object any more.
 java.util.Map<java.lang.String,Property> getRequiredProperties()
          The properties that this action requires on a TextObject.
 

Method Detail

behave

Action.ActionResult behave(TextObject to)
Performs the action on a TextObject.


behave

Action.ActionResult behave(TextObject toA,
                           TextObject toB)
Performs the action on a pair of TextObjects


behave

Action.ActionResult behave(TextObject[] to)
Performs the action on a set of TextObjects


complete

void complete(TextObject to)
Inform an Action that it won't need to work on this object any more.

This is a forced completion of an action. When this method is called, an action should clean up any state it is maintaining for the provided TextObject. The action may be called again with that TextObject, but this case will be considered as starting the action again.

There is no need for a corresponding start() method, since that information is implicitly included in the first call to behave().


getRequiredProperties

java.util.Map<java.lang.String,Property> getRequiredProperties()
The properties that this action requires on a TextObject.

When the behave() method of an action is called, it will be assumed that these properties have been set on the object. This initialization is usually handled by the Behaviour containing the action.

Typically an Action inherits the implementation of this method from a base class, such as AbstractAction or PhysicsAction.