in , , , , ,

Enumeration Finally Added To GameMaker Studio

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

What do you think?

6 Comments

Leave a Reply
    • 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.

  1. 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.

    • how can you accomplish this without using “enum” my version of game maker doesn’t seem to have it and i can’t update it

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

GameMaker Studio Ranks #35 On Develop’s Top 100 Tech List

GameMaker Summer Sale – Up To 50% Off