Cauldron2D.GameMaker.Event (Cauldron2D.GameMaker v0.2.1)

Copy Markdown View Source

GameMaker's event types, and the names its compiler gives each event's code.

The type's number is its place in an object's event list:

numbertypesubtype
0:create0
1:destroy0
2:alarmalarm number, 0–11
3:step0 step, 1 begin step, 2 end step
4:collisionthe other object's index
5:keyboardkey code, held
6:mousemouse event number
7:otherother event number: 10–25 are user events 0–15
8:draw0 draw, 64 draw GUI, 72/73 draw begin/end, …
9:key_presskey code
10:key_releasekey code
11:triggertrigger number
12:clean_up0
13:gesturegesture number
14:pre_create0

A game compiled to native code keeps each event's code in its executable as a function named gml_Object_<object>_<Type>_<subtype>, the subtype of a collision event being the other object's name: handler_name/3 builds that name.

Summary

Functions

The name of the compiled function for object's event type with subtype, where a collision's subtype is the other object's name.

The event type numbered number.

Every event type, in number order.

Types

type()

@type type() ::
  :create
  | :destroy
  | :alarm
  | :step
  | :collision
  | :keyboard
  | :mouse
  | :other
  | :draw
  | :key_press
  | :key_release
  | :trigger
  | :clean_up
  | :gesture
  | :pre_create
  | {:unknown, non_neg_integer()}

Functions

handler_name(object, type, subtype)

@spec handler_name(String.t(), type(), non_neg_integer() | String.t()) :: String.t()

The name of the compiled function for object's event type with subtype, where a collision's subtype is the other object's name.

iex> Cauldron2D.GameMaker.Event.handler_name("Moon", :step, 2)
"gml_Object_Moon_Step_2"
iex> Cauldron2D.GameMaker.Event.handler_name("CatMoveLeft", :collision, "Cat")
"gml_Object_CatMoveLeft_Collision_Cat"

type(number)

@spec type(non_neg_integer()) :: type()

The event type numbered number.

types()

@spec types() :: [type()]

Every event type, in number order.