var STATE = cc.Enum
({
ERROR: -1,
OK: 0,
STATE_ONE: 1
}),
It show up an error: 1 already defined in Enum, seem like I can’t use negative number in the enum.
I’m porting codes from another project (of other team in my company), which already completed and the server shouldn’t be changed. Are there any flags in Cocos Creator to solve this problem?
If a enum item has a value of -1, it will be given an Integer number according to it’s order in the list.
Otherwise it will use the value specified by user who writes the enum definition.
I have encountered the same problem a while ago, you can assign string to the properties in enum, then use parseInt to convert back to integer when needed