When I code in Dart or Java I tend to define a class - typically I call it Statics - where I define the various constants ; integers, strings…; that are referenced from two or more locations within the project. This makes things a lot more bug proof and handles issues arising out of typos nicely. It is not immediately clear to me how I should do this in Defold. The case in point
- I am using multiple factories to create a subset of sprites to populate a scene
- Once all those sprites have been generated I configure their local attributes - initiated in their init functions - by passing a sequence of messages from the factory script
- Needless to say in the script associated with the sprite in its prototype the relevant on_message function has to trap these messages and do the necessary
Now, I don’t like having to type in the message_id string twice - once in the factory script and then again in the sprite prototype script. What would be the standard way of avoiding this?