What are the enumerations?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lalel345

What are the enumerations? I saw that they are named in the documentation

:bust_in_silhouette: Reply From: klaas

Hi,
enumerations or short enum are a collection of numbered literal constants.

Just like

const MY_CONST = 234

but enums are defiened differently

enum {TILE_BRICK, TILE_WATER, TILE_SKY}

then TILE_BRICK would be 0 TILE_WATER = 1 and so on

If you would want more structured code you can do

enum tiles {TILE_BRICK, TILE_WATER, TILE_SKY}

Then tiles.TILE_BRICK would be 0 etc.

and since they are constant they are static too
MyCustomClass.tiles.TILE_BRICK is also accessible

I could do it with the body entered signal of an area to detect when there is something over this?

lalel345 | 2020-08-19 09:47

How do we know enums are static? I can make another question if need be.

DDoop | 2020-08-19 19:46

Well … they are. Like any other constant in gd script

klaas | 2020-08-19 20:01

Ok, thank you :slight_smile:

DDoop | 2020-08-19 20:02