net.nexttext.behaviour.control
Class OnCollision

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.control.OnCollision
All Implemented Interfaces:
Action

public class OnCollision
extends AbstractAction

This control applies an Action when an object overlaps with another object.

Objects affected by a OnCollision action must be added to the SpatialList, otherwise the behave() method will catch an exception.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
OnCollision(Action action)
          Creates an OnCollision which applies the specified Action to every object that are being collided with.
 
Method Summary
 Action.ActionResult behave(TextObject to)
          For each object this one is colliding with, apply the action to the pair of colliding objects.
 java.util.Map<java.lang.String,Property> getRequiredProperties()
          The properties that this action requires on a TextObject.
 
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

OnCollision

public OnCollision(Action action)
Creates an OnCollision which applies the specified Action to every object that are being collided with.

Method Detail

behave

public Action.ActionResult behave(TextObject to)
For each object this one is colliding with, apply the action to the pair of colliding objects.

The results of the called actions are combined using the method outlined in ActionResult.

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

getRequiredProperties

public java.util.Map<java.lang.String,Property> getRequiredProperties()
Description copied from class: AbstractAction
The properties that this action requires on a TextObject.

Right now this method always returns an empty map, since basic Actions should be restricted to use only the core set of TextObject properties.

If a subclass of Action requires a set of additional properties then it should override this method and return the appropriate Map containing the property objects.

This method is required by the Action interface.

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