net.nexttext.behaviour.physics
Class StayInside

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

public class StayInside
extends PhysicsAction

StayInside tries to keep an object inside a Shape. Most likely, you will want to combine this action with another one which moves the object inside the Shape first.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
StayInside(java.awt.Shape shape)
          This constructor sets jiggle to 3 by default.
StayInside(java.awt.Shape shape, float jiggle)
           
 
Method Summary
 Action.ActionResult behave(TextObject to)
          Jiggles the object until it's fully contained inside the shape.
 java.awt.Shape getShape()
           
 void setShape(java.awt.Shape shape)
           
 
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
 

Constructor Detail

StayInside

public StayInside(java.awt.Shape shape,
                  float jiggle)
Parameters:
shape - an area to remain inside of.
jiggle - is number of pixels to jiggle object to keep it inside.

StayInside

public StayInside(java.awt.Shape shape)
This constructor sets jiggle to 3 by default.

Parameters:
shape - an area to remain inside of.
Method Detail

behave

public Action.ActionResult behave(TextObject to)
Jiggles the object until it's fully contained inside the shape. Also slows down the object's velocity if it's trying to move outside.

The returned ActionResult will include an event each time the object is jiggled to keep it inside.

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

getShape

public java.awt.Shape getShape()

setShape

public void setShape(java.awt.Shape shape)