Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics


Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

GMLive and singleton - solution

A topic by gnysek created Feb 13, 2023 Views: 148
Viewing posts 1 to 1
(1 edit)

GM 2023.1 introduced singletons:

function foo() constructor {
  static bar = 1;

foo(); // initialised at least once so static is set

/// now you can do this anywhere:; // returns 1

However, GMLive (yet) doesn’t support this syntax. There’s however very easy way to bypass this issue. Instead of you need to write static_get(foo).bar - as in fact while compiling, GM translates former to latter, which means only latter is used in compiled games.

Have fun playing with new syntax!