Is there a reason I cannot select from a list of my functions? It's not always easy to remember the names. I have to keep looking around for them. Would be nice if I could at least see a list of them somewhere. ;)
This has been proposed a couple of times, not just in regards to functions but anything that is user defined and identified by name, variables, objects, families, etc... I am hoping it makes it in at some point...
If you can only pick from a list of existing functions, there needs to be some different way to create a new function. That makes it a little more complicated than just adding, say, a dropdown for existing layouts. It's on the todo list though.
Until an in engine solution is created. I have another suggestion.
Use and Array, but not the Array fields. An Array is considered a global object. An Array can have variables. There can be more than one Array. So let me write a psuedo example of what you can do.
This is your array object. It has the name Colour
Colour // this is your array object
var fnPickColour = "colourPickColour"
var fnGetColour = "colourGetColour"
var fnFoo = "colourfoo"
this is the sample OnFunction Calls. Ie the function event. Instead of writing out a string. Instead you reference a variable.
When calling the function. as you can see now. Your not writing a string.
Best of all if you
a drop down list of the variables stored in the arry(with the array function expression). By putting somekind of camel hump notation after the period similar to fn(FuNction) the dropdown list will sort out.
It's not perfect, but it does work. Also it also requires the developer to create the functions prior to there use.
Not a bad work around actually. A little extra work, but it should do for now. ;)
Edit: For those reading, I just realized that I can also "group" some logic in an "on created" event - so as far as "grouping" sprites together" goes, that helps.
I use global constants to hold function names - then when I need to call a function, I can just pick it from my globals list. Has the added benefit of allowing me to enter in a comment that tells me what the function does, what it returns and/or what parameters it takes.
I usually keep an event sheet called Function Headers, and try to stick to a naming convention like F_FUNCTION_NAME - that way, when looking through globals, I can see all of the functions grouped together. Then I can quickly look at the comment to see how to use it properly.
It's a bit of extra work (and some overhead for the globals as well), but definitely helps to keep things organized. Of course, some sort of built in method of organizing functions would be awesome :)
Develop games in your browser. Powerful, performant & highly capable.
rogueNoodle. I thought about globalization the function names. It works really well. The benefit is that the it get's to the function string faster. However, I felt the benefits of using an Array work out a little bit better. I'm not doing this to say golbal function vars are wrong. Just weighing in the difference so people who like both can compare for their needs. If you can add anything that I may miss please do so :)
Also I change my mind. Instead of an Array. Use Dictionary instead.
Global Function names
+ Function names are type safe
+ No require "" string ends
+ Short naming conventions allowed
~ Stronger notation for organization(if desired)
~ fantastic for smaller projects or fewer features
Object Function names
+ No required "" string ends
+ objective naming convention for organization
+ provides on function name auto-complete(ie "object.xxxx" )
+ Dictionary can provide it's own variable storage for runtime data
~ not bound to the event sheet
~ maybe more overhead for smaller projects than it's worth.
Looking at this. I wish I started my current project using these design guide. I was neck deep into current development before thinking of this.
Personally I would like an open Object that we can treat as a custom defined class. Then again the dictionary works really well except for cluttering up the expressions for the object.
jayderyu - That looks about right. The project size definitely plays a factor, as I'm starting to find adding globals for every function is a little tedious. I actually didn't think it was necessary to include an event sheet in order to have access to the globals, but to be honest, I'm not sure why I thought that...
Having a better look at your method, I definitely see the benefits in it - will probably use that method for my next project.
jayderyu ; rogueNoodle :
You don't need to include an event sheet to have access to global variables defined in it. Those global variables are global to the whole project.
The dictionary though needs to be set as a global object, possibly created in the very first layout of your project and filled at that moment. Once it is filled, no need to do it again.
Yep. I stand corrected. That was an over sight of my part :P
NM, I ran it off as a theory. Since JS would allow this kind of theory. However, after shifting one of my prototypes over to the design. It won't work. Function OnFunction"" must be a constant. Not a variable of anykind. So I also tried global's. which didn't work either :|
it seems that the On Function even requires a string. This is annoying. However it can still work Action and OnCall.