Class WorldEvent

java.lang.Object
com.codename1.gaming.platformer.WorldEvent

public final class WorldEvent extends Object
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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A spring launched an actor.
    static final int
    A checkpoint was reached.
    static final int
    The level was completed.
    static final int
    A block crumbled.
    static final int
    An actor dashed.
    static final int
    An actor died.
    static final int
    A weapon fired.
    static final int
    The player ran out of lives.
    static final int
    An actor was hurt.
    static final int
    A projectile hit something.
    static final int
    An actor jumped.
    static final int
    An actor landed.
    static final int
    A door opened or a gate changed.
    static final int
    A pickup was collected; detail is its kind name.
    static final int
    The player stomped an enemy.
    static final int
    A switch was activated.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WorldEvent(int type, int x, int y, String subject, String detail)
    Creates an event.
  • Method Summary

    Modifier and Type
    Method
    Description
    Extra information.
    The id of the actor or entity involved.
    int
    The event type.
    int
    Where it happened.
    int
    Where it happened.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • WorldEvent

      public WorldEvent(int type, int x, int y, String subject, String detail)

      Creates an event.

      Parameters
      • type: one of the constants
      • x: where, fixed point
      • y: where, fixed point
      • subject: the id of the actor or entity involved, may be null
      • detail: 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