Struct Singletons

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 6

  • @EnderPlayed-lp9ko
    @EnderPlayed-lp9ko 3 роки тому +5

    im a really big fan of gamemaker, I also buyed it, bit I cant get one example where this is effective

    • @SamSpadeGameDev
      @SamSpadeGameDev  3 роки тому +4

      I use it regularly for things that need to exist for the entire game, and hold data, but don't need to run events. A pubsub manager is a good example. Another way to think of it is, if you have a persistent object, that doesn't use any events (e.g. step, draw, etc) you could probably replace it with a global struct created in a script asset.

    • @potatocat94
      @potatocat94 10 місяців тому

      @@SamSpadeGameDev Wish I have seen this a year before, thanks for your shorts!

  • @DrTomb
    @DrTomb 6 місяців тому +1

    Wait, so you dont need to out global on it. I got mixed messages when you used global on the top struct but not the bottom ones.

  • @roobidium
    @roobidium 2 роки тому +1

    Would this system work for a particle manager? I know that particle systems need to be cleaned up to prevent memory leaks, but would that be necessary in a script?

    • @SamSpadeGameDev
      @SamSpadeGameDev  2 роки тому +2

      It probably wouldn't work as structs don't have step events, or any events, and you normally want that for a particle system, but you can do a similar thing with objects and that might depending on what your possible system looks like.