Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class WorldEvent
- Object
- WorldEvent
Something that happened in a tick that a view should show or play: a jump, a
coin, a hit. The simulation never calls into a view; it records events, and the
view reads
PlatformWorld#getEvents() after each step to trigger sounds,
particles and screen shake.Fields
public static final int JUMP = 1 | An actor jumped. |
public static final int LAND = 2 | An actor landed. |
public static final int PICKUP = 3 | A pickup was collected; detail is its kind name. |
public static final int HURT = 4 | An actor was hurt. |
public static final int DEATH = 5 | An actor died. |
public static final int STOMP = 6 | The player stomped an enemy. |
public static final int FIRE = 7 | A weapon fired. |
public static final int IMPACT = 8 | A projectile hit something. |
public static final int CHECKPOINT = 9 | A checkpoint was reached. |
public static final int BOUNCE = 10 | A spring launched an actor. |
public static final int OPEN = 11 | A door opened or a gate changed. |
public static final int CRUMBLE = 12 | A block crumbled. |
public static final int DASH = 13 | An actor dashed. |
public static final int COMPLETE = 14 | The level was completed. |
public static final int GAME_OVER = 15 | The player ran out of lives. |
public static final int SWITCH = 16 | A switch was activated. |
Constructors
public WorldEvent(int type, int x, int y, String subject, String detail) | Creates an event. |
Methods
public int getType() | The event type. |
public int getX() | Where it happened. |
public int getY() | Where it happened. |
public String getSubject() | The id of the actor or entity involved. |
public String getDetail() | Extra information. |
Inherited methods
Field details
JUMP
public static final int JUMP = 1An actor jumped.
LAND
public static final int LAND = 2An actor landed.
PICKUP
public static final int PICKUP = 3A pickup was collected;
detail is its kind name.HURT
public static final int HURT = 4An actor was hurt.
DEATH
public static final int DEATH = 5An actor died.
STOMP
public static final int STOMP = 6The player stomped an enemy.
FIRE
public static final int FIRE = 7A weapon fired.
IMPACT
public static final int IMPACT = 8A projectile hit something.
CHECKPOINT
public static final int CHECKPOINT = 9A checkpoint was reached.
BOUNCE
public static final int BOUNCE = 10A spring launched an actor.
OPEN
public static final int OPEN = 11A door opened or a gate changed.
CRUMBLE
public static final int CRUMBLE = 12A block crumbled.
DASH
public static final int DASH = 13An actor dashed.
COMPLETE
public static final int COMPLETE = 14The level was completed.
GAME_OVER
public static final int GAME_OVER = 15The player ran out of lives.
SWITCH
public static final int SWITCH = 16A switch was activated.
Constructor details
WorldEvent
public WorldEvent(int type, int x, int y, String subject, String detail)Creates an event.
Parameters
typeint- one of the constants
xint- where, fixed point
yint- where, fixed point
subjectString- the id of the actor or entity involved, may be null
detailString- extra information such as a pickup kind, may be null
Method details
getType
public int getType()The event type.
Returns
one of the constants
getX
public int getX()Where it happened.
Returns
x, fixed point
getY
public int getY()Where it happened.
Returns
y, fixed point
getSubject
public String getSubject()The id of the actor or entity involved.
Returns
the id, or null
getDetail
public String getDetail()Extra information.
Returns
the detail, or null