net.nexttext.behaviour.physics
Class StayInside
java.lang.Object
net.nexttext.behaviour.AbstractAction
net.nexttext.behaviour.physics.PhysicsAction
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.
Constructor Summary |
StayInside(java.awt.Shape shape)
This constructor sets jiggle to 3 by default. |
StayInside(java.awt.Shape shape,
float jiggle)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
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)