I am kinda new to Construct 2 (and loving it, btw) and I always try to keep my code (or events, for this particular matter) as clean and tidy as possible. I would like to know what is the best approach option for two particular cases I am facing in my development in terms of performance and efficiency.
Case 1: The Player variables
I have this Player object with many attributes (namely Health, Power and Speed). I have to access those attributes from many different layouts because they will be changed by equipping items on menus and will also affect the game itself, during combat. I figured that I can't set those as instances variables for the Player object because they will be changed on layouts where the Player object is not present.
Then, I can either:
(if there are any other ways to setting these up, please let me know).
And set them "on load finished" or on my first layout.
Case 2: The slot system
I am setting up a slot machine system. Once every X seconds, 3 variables will be randomly set and, depending on their combination, give the Player a special power. I have to set up those individual powers manually (789 powers to go! Woohoo!), but I have to store their names, properties, damage and other attributes somewhere.
I can either:
These "Powers" would be set on "layout start" when the game level finishes loading (I guess?)
My question is, for both cases, what would be the most efficient and clean approach?
Thanks in advance!
Develop games in your browser. Powerful, performant & highly capable.
I think everyone has his own methods.
For me, globals are last resort.
Instance variables are very usefull within layout. To identify instances and set/get instance status.
If I have more instances frome same type to set to something, I use locals. Because you cant pick from same type twice.
Finally, to have a database over all layouts, there are dictionary and array, but for me they are to inflexible, so I build my own.