net.nexttext.behaviour.physics
Class Approach

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.physics.PhysicsAction
          extended by net.nexttext.behaviour.physics.Approach
All Implemented Interfaces:
Action, TargetingAction

public class Approach
extends PhysicsAction
implements TargetingAction

Approach applies an acceleration which tries to push the object in the direction of its target.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
Approach(float x, float y)
          Constructor creates a Approach at x,y with a default speed and hitRange.
Approach(float x, float y, float z)
          Constructor creates a Approach at x,y,z with a default speed and hitRange.
Approach(float x, float y, float z, float speed, int hitRange)
          Constructor creates a Approach at x,y,z.
Approach(float x, float y, float speed, int hitRange)
          Constructor creates a Approach at x,y.
Approach(Locatable target)
          Creates an Approach action at a certain target with default speed of 10 and hitRange or 2.
Approach(Locatable target, float speed, int hitRange)
           
Approach(Locatable target, float speed, int hitRange, boolean canComplete)
           
 
Method Summary
 Action.ActionResult behave(TextObject to)
          Applies an acceleration towards the target, with a magnitude proportional to the Speed property.
 void setTarget(float x, float y)
          Sets a target to approach.
 void setTarget(float x, float y, float z)
          Sets a target to approach.
 void setTarget(Locatable target)
          Sets a target to approach.
 void setTarget(processing.core.PVector target)
          Sets a target to approach.
 
Methods inherited from class net.nexttext.behaviour.physics.PhysicsAction
applyAcceleration, applyAngularAcceleration, applyAngularForce, applyForce, getAngularVelocity, getMass, getRequiredProperties, getVelocity
 
Methods inherited from class net.nexttext.behaviour.AbstractAction
behave, behave, complete, getDisplayName, makeBehaviour, properties, setDisplayName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.nexttext.behaviour.Action
behave, behave, complete, getRequiredProperties
 

Constructor Detail

Approach

public Approach(Locatable target,
                float speed,
                int hitRange)
Parameters:
speed - controls the magnitude of the acceleration applied in the direction of the target
hitRange - this value is used as a radius around the target to determine if Approach has reached its location. A hitRange of 1 means that Approach will not return done unless the object is right on target.

Approach

public Approach(Locatable target,
                float speed,
                int hitRange,
                boolean canComplete)
Parameters:
canComplete - indicates whether this action should ever complete. If set to false, then textObjects will stop moving once they enter the hitRange, but will start moving again if the object to be followed moves out of the hitRange.

Approach

public Approach(Locatable target)
Creates an Approach action at a certain target with default speed of 10 and hitRange or 2.

Parameters:
target -

Approach

public Approach(float x,
                float y,
                float speed,
                int hitRange)
Constructor creates a Approach at x,y.

Parameters:
x -
y -
speed -
hitRange -

Approach

public Approach(float x,
                float y)
Constructor creates a Approach at x,y with a default speed and hitRange.

Parameters:
x -
y -

Approach

public Approach(float x,
                float y,
                float z)
Constructor creates a Approach at x,y,z with a default speed and hitRange.

Parameters:
x -
y -
z -

Approach

public Approach(float x,
                float y,
                float z,
                float speed,
                int hitRange)
Constructor creates a Approach at x,y,z.

Parameters:
x -
y -
z -
speed -
hitRange -
Method Detail

behave

public Action.ActionResult behave(TextObject to)
Applies an acceleration towards the target, with a magnitude proportional to the Speed property.

Result is complete if it has reached its target.

Specified by:
behave in interface Action
Overrides:
behave in class AbstractAction

setTarget

public void setTarget(float x,
                      float y)
Sets a target to approach.

Specified by:
setTarget in interface TargetingAction

setTarget

public void setTarget(float x,
                      float y,
                      float z)
Sets a target to approach.

Specified by:
setTarget in interface TargetingAction

setTarget

public void setTarget(processing.core.PVector target)
Sets a target to approach.

Specified by:
setTarget in interface TargetingAction

setTarget

public void setTarget(Locatable target)
Sets a target to approach.

Specified by:
setTarget in interface TargetingAction