Enumeration Finally Added To GameMaker Studio

on July 6, 2014 - 14511 Views

A recent Early Access build has introduced C-style enumeration to GameMaker Studio, an overdue feature that will be welcomed by veteran coders. Enumerations consist of named integer constants called “members” or “enumerators”.

An example is shown below.

gamemaker-enumeration

In the example, an enumeration with a set of 7 members is declared. The constant values of the members range from 1 to 7. The enumeration can then be referenced in the manner shown.

Learn more about enumeration »

A copy of the code used in the example can be found below. You can paste this directly into GameMaker.

enum DAY { //declare enum type
    sun,
    mon,
    tue,
    wed,
    thu,
    fri,
    sat
};
 
var example = DAY.thu;

show_message(string(example)); //output: 5

Recent Posts

4 Responses to Enumeration Finally Added To GameMaker Studio

  1. var test = {
    test1: 123,
    test2: 456
    }

    show_message(string(test.test2)); //output is 456

    Will that work?

    • Toni says:

      This will work:

      enum TEST {
      foo = 1,
      bar = 2,
      john = foo + bar,
      dooh = john +5
      }

      Colo notattion is not working, also you can’t assign string values to enum list.

  2. I saw this the same day it was announced, and although it can be achieved by other means, it’s simpler to create this type of data structures this way :D.

  3. Snail_Man says:

    Seems rather useful, but it could be similarly accomplished by using constants. Still, I suppose for local scripts, it would be useful for increasing readability.

Leave a Reply

Your email address will not be published. Required fields are marked *

UA-103187421-1