GM: Events

From GMpedia.org Wiki

Jump to: navigation, search

Events in Game Maker are one of the top four Game Maker concepts. An event is the occasion where an object would perform a set of actions. Otherwise, the Object wouldn't know when show these actions be performed.

Contents

[edit] Create Event

The create event is the event where its actions are called at the moment the object is created (created in the room).

[edit] Destroy Event

The destroy event is the event where its actions are called at the moment where the object is destroyed (removed from the room).

[edit] Alarm Event

Alarm event is really great, there are 8 alarm events available, (Alarm 0 -> Alarm 7). In another event you set the alarm to a particular time of milliseconds. If the alarm0 is set to 5 for example, after 5 milliseconds (discussed later) the actions in alarm0 are executed.

[edit] Step Event

Step event is done all the time; every one millisecond the event is executed again. A step event in Game Maker consists of three sub-events:

  • Begin Step: The begin step is executed every millisecond, like all step events, but it is executed before them, the begin step is executed before any event in this millisecond occurs.
  • Normal Step: The step event is executed just before instances are put in their new positions.
  • End Step: End step is executed after all events are executed in this millisecond.

[edit] Collision Event

In the collision event, actions are performed when an object collides with a certain object. When clicking on the "Collision Event" button, you will see a menu containing the names of all the objects. You select an object, and it will be the collision event with that object. Don't understand? Here is an example object1 is the bullet and object2 is the enemy, in the object2 code, it must be destroyed when it collides with object1. Simply inside the object properties of object2 (the enemy) click on the collision event button and you will see a list of all the objects, select object1 (the bullet), this means the object2 will perform the list of actions when object1 collides with it. Next you can put the required action inside the box on the left.

[edit] Keyboard Event

The keyboard event is executed whenever a key is pressed. A key can be a letter, a function key, a number, a direction, or any key located in the keyboard. If you hold a key down, the event will keep executing untill the key is released.

[edit] Key press Event

This event is executed only when the key is first pressed. That means that it is executed once every time the key is pressed.

[edit] Key release Event

This event is executed only when the key that was pressed is released. That means that it is executed once when the key is released.

[edit] Mouse Event

[edit] Mouse Button Event

Mouse events have three types:

  1. . Mouse button: Called whenever a mouse button is pressed and is hovering the object, just like the keyboard event.
  2. . Mouse press: Called only once when the button is first clicked, in order to be called again, the mouse must be released and pressed again.
  3. . Mouse release: Called only once the mouse is released.

Note: mouse button events occur only when the mouse is over the sprite associated with the object.

[edit] Mouse Enter and Leave Events

Mouse enter and leave events are called once the mouse enters or leaves the object. I.e., when the mouse hovers the sprite associated with the objects or stops hovering it.

[edit] Mouse Wheel Events (Up and Down)

Are executed when the mouse wheel is scrolled up or down.

[edit] Global Mouse Events

Global mouse includes many sub-events underneath it, it is almost identical to the Mouse button events, except that they are executed wherever the mouse is located.

[edit] Other Events

The other event has many sub-events in it:

  • Outside Room: Whenever the object is outside the room
  • Intersect Boundary: Whenever the object touches the boundary of the room.
  • Game Start: Whenever the game starts.
  • Game End: Whenever the game ends.
  • Room Start: Whenever the room starts.
  • Room End: Whenever the room ends.
  • No More Lives: When the player has no more lives.
  • No More Health: When the player has no more health.
  • Animation End: Whenever the sprite associated to the object is done animating.
  • End of path: When the object is done of performing its path.
  • User defined: User defined

[edit] See Also

Personal tools