|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.emini.physics2D.Event
public class Event
The Event class represents a generic event that can be triggered in the world.
The world checks all registered event for its triggers.
The event can have filters:
- TYPE_BODY_POSITION - target1, target2 -> upper left edge of check area - target3, target4 -> lower right edge of check area - TYPE_BODY_VELOCITY - velocity in pixel per second - target1, target2 -> lower upper limit of speed - target3, target4 -> irrelevant - TYPE_BODY_ROTATION - target1, target2 -> lower and upper limit for the rotation (rotation is always [0;360] - target3, target4 -> irrelevant - TYPE_BODY_ANGULARVELOCITY - target1, target2 -> lower and upper limit for the angular velocity (in degrees per second), can be negative - target3, target4 -> irrelevant - TYPE_BODY_COLLISION - target1 > 0 -> trigger upon collisions north (negative y) - target2 > 0 -> trigger upon collisions east (positive x) - target3 > 0 -> trigger upon collisions south (position y) - target4 > 0 -> trigger upon collisions west (negative x) - TYPE_BODY_COLLISION_RELATIVE (this event is created using its particular method) - target1, target2 -> the default direction - target3 -> the allowed deviation from the directionAn event can be "trigger once" which causes the event to be raised exactly once as long as the condition is met. When at some time the condition is not met anymore, the event can be raised again for this parameter.
Field Summary | |
---|---|
protected UserData |
mUserData
User data |
static int |
TYPE_BODY_ANGULARVELOCITY
Event type angular velocity. |
static int |
TYPE_BODY_COLLISION
Event type collision. |
static int |
TYPE_BODY_COLLISION_RELATIVE
Event type collision. |
static int |
TYPE_BODY_POSITION
Event type position. |
static int |
TYPE_BODY_ROTATION
Event type rotation. |
static int |
TYPE_BODY_SENSOR
Event type area collision. |
static int |
TYPE_BODY_VELOCITY
Event type velocity. |
static int |
TYPE_CONSTRAINT_FORCE
Event type constraint force. |
Constructor Summary | |
---|---|
protected |
Event(Body bodyFilter,
Shape shapeFilter,
Constraint constraintFilter,
int type,
float target1FX,
float target2FX,
float target3FX,
float target4FX,
java.lang.Object target)
Constructor. |
protected |
Event(Event other,
Body[] bodyMapping)
Copy Constructor. |
protected |
Event(int type)
Empty Constructor. |
Method Summary | |
---|---|
boolean |
checkEvent(World world,
PhysicsEventListener listener)
Checks if the event is currently active. |
Event |
copy(Body[] bodyMapping)
Copies the event. |
static Event |
createBodyEvent(Body bodyFilter,
Shape shapeFilter,
int type,
int target1,
int target2,
int target3,
int target4)
Creates a body event. |
static Event |
createBodySensorEvent(Body bodyFilter,
Shape shapeFilter,
Body sensor)
Creates an area collide event. |
static Event |
createCollisionRelativeEvent(Body bodyFilter,
Shape shapeFilter,
int startAngle,
int endAngle)
Creates a relative collision event. |
static Event |
createConstraintEvent(Constraint constraintFilter,
int type,
int target1,
int target2)
Creates a constraint event. |
Body |
getBodyFilter()
Gets the body filter. |
Constraint |
getConstraintFilter()
Gets the constraint filter. |
int |
getIdentifier()
Gets the event identifier. |
Shape |
getShapeFilter()
Gets the shape filter. |
java.lang.Object |
getTargetObject()
Return the target object. |
boolean |
getTriggerOnce()
Gets the trigger once flag. |
UserData |
getUserData()
Get user data. |
static Event |
loadEvent(PhysicsFileReader reader,
World world,
UserData userData)
Loads an event from stream. |
void |
setBodyFilter(Body b)
Sets the body filter. |
protected void |
setConstraintFilter(Constraint c)
Sets the constraint filter. |
void |
setScript(Script script)
Sets the execution script. |
void |
setShapeFilter(Shape s)
Sets the shape filter. |
protected void |
setTargetsFX(float target1FX,
float target2FX,
float target3FX,
float target4FX)
Sets all targets. |
void |
setTriggerOnce(boolean triggerOnce)
Flag whether event should be triggered more than once in a row. |
void |
setUserData(UserData userData)
Set User data |
protected float |
targetAFX()
Gets the targetA |
protected float |
targetBFX()
Gets the targetB |
protected float |
targetCFX()
Gets the targetC |
protected float |
targetDFX()
Gets the targetD |
int |
type()
Gets the event type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_BODY_POSITION
public static final int TYPE_BODY_VELOCITY
public static final int TYPE_BODY_ROTATION
public static final int TYPE_BODY_ANGULARVELOCITY
public static final int TYPE_BODY_COLLISION
public static final int TYPE_BODY_COLLISION_RELATIVE
public static final int TYPE_BODY_SENSOR
public static final int TYPE_CONSTRAINT_FORCE
protected UserData mUserData
Constructor Detail |
---|
protected Event(Body bodyFilter, Shape shapeFilter, Constraint constraintFilter, int type, float target1FX, float target2FX, float target3FX, float target4FX, java.lang.Object target)
bodyFilter
- the body to which this event applies, null if all.shapeFilter
- the shape (=group of bodies) to which this event applies, null if all.constraintFilter
- the constraint to which this event applies, null if all.type
- the type of the event (must be consistent to the used filter).target1FX
- the target 1target2FX
- the target 2target3FX
- the target 3target4FX
- the target 4protected Event(Event other, Body[] bodyMapping)
other
- the event to copy.bodyMapping
- the mapping of bodies in the new world (null if not used).protected Event(int type)
type
- type of the event.Method Detail |
---|
public static Event createBodyEvent(Body bodyFilter, Shape shapeFilter, int type, int target1, int target2, int target3, int target4)
bodyFilter
- the body to which this event applies, null if all.shapeFilter
- the shape (=group of bodies) to which this event applies, null if all.type
- the type of the event (can only be a BODY event type).target1
- the target 1target2
- the target 2target3
- the target 3target4
- the target 4public static Event createCollisionRelativeEvent(Body bodyFilter, Shape shapeFilter, int startAngle, int endAngle)
bodyFilter
- the body to which this event applies, null if all.shapeFilter
- the shape (=group of bodies) to which this event applies, null if all.startAngle
- start angleendAngle
- end anglepublic static Event createBodySensorEvent(Body bodyFilter, Shape shapeFilter, Body sensor)
bodyFilter
- the body to which this event applies, null if all.shapeFilter
- the shape (=group of bodies) to which this event applies, null if all.sensor
- The sensor body that is not physically present, but is used only for event checking.public static Event createConstraintEvent(Constraint constraintFilter, int type, int target1, int target2)
constraintFilter
- the constraint to which this event applies, null if all.type
- the type of the event (can only be a CONSTRAINT event type).target1
- the target 1target2
- the target 2public Event copy(Body[] bodyMapping)
Body.Body(Body)
).
bodyMapping
- the mapping of bodies in the new world (null if not used).
public static Event loadEvent(PhysicsFileReader reader, World world, UserData userData)
reader
- the file reader representing the data streamworld
- the world for correct referencing of bodies/constraints used by the event
public int getIdentifier()
public int type()
public void setScript(Script script)
script
- the script to execute.public void setBodyFilter(Body b)
b
- the body for which the event applies to.public Body getBodyFilter()
public void setShapeFilter(Shape s)
s
- the shape (= group of bodies) for which the event applies to.public Shape getShapeFilter()
public java.lang.Object getTargetObject()
protected void setConstraintFilter(Constraint c)
c
- the constraint filter for event triggering.public Constraint getConstraintFilter()
protected float targetAFX()
protected float targetBFX()
protected float targetCFX()
protected float targetDFX()
protected void setTargetsFX(float target1FX, float target2FX, float target3FX, float target4FX)
target1FX
- the target 1target2FX
- the target 2target3FX
- the target 3target4FX
- the target 4public void setTriggerOnce(boolean triggerOnce)
triggerOnce
- new value of trigger oncepublic boolean getTriggerOnce()
public boolean checkEvent(World world, PhysicsEventListener listener)
world
- the worldlistener
- the event listener
public UserData getUserData()
public void setUserData(UserData userData)
userData
- the user data
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |