Like this (using the example of various AI states for an AI State Machine):
And then you can assign any value from that enum to a variable, like this:
In the above example, the variable's type is implicitly defined as "AIState". You can explicitly define a variable with that type like this:
And similarly you can define the input parameter of a function to recieve a value from your enum, like this:
You can also assign values to your individual enum elements.
This is incredibly helpful if you use layers, for example. Rather than using
You could instead use the easier to read
This is especially helpful as there is then only one location, your enum, where you have to change the layer number if a change is needed.
answered Apr 13, 2011 at 02:03 PM