Any problem in creating and deleting buttons all the time?
Posted: Tue Sep 10, 2019 2:36 pm
I have used to programming using layers. However, with my latest game (still havent got to final release it, but soon perhaps) I instead tried non layer approach, and I liked it quite much actually and I am now thinking using it in my next project too.
As I am thinking on how to solve the buttons problems, one thought came to my mind, but I wonder if it is actually safe to do so, or can it cause some problem.
In layers approach, my buttons work so that they are calling a Function called for example "VirtualButtonFunction1"'.
This VirtualButtonFunction is very simple:
By otherwords, this button function was simply calling the real function.
Reason for this was because sometimes I wanted to change the button function on fly. That lets say normally I wanted a button click to shoot, but then suddenly I wanted the same button to instead shoot a missile or not even do anything at all. Since Hollywood dont let you change button functions on fly, I made this call to another function, since this RealButtonFunction could be changed on fly.
Since I like to have this same functionality of changing buttons on fly in this non layer approach too, what I have in my mind is following:
I would have a table called "table_Buttons".
then when ever I want some button to exist, i would throw it to that list of buttons.
Then there be a command like ButtonsCreate() which would create all those buttons currently in that list of buttons.
If I want to change function of one button, I would first use ChangeButtonFunction() command, which would affect Teble_button.ID.function
and then I would call ButtonsCreate() again, which would first delete all currently existing button, and then create them again based upon all on that button list.
From progamming point of view this seems to me like a good solution for my problems, but I am worried will it be a problem if I continuously keep deleting and creating buttons? As example, if one button is removed (for example some game menu closed) it means all buttons would be created again after to be deleted ones are removed from list first.
As I am thinking on how to solve the buttons problems, one thought came to my mind, but I wonder if it is actually safe to do so, or can it cause some problem.
In layers approach, my buttons work so that they are calling a Function called for example "VirtualButtonFunction1"'.
This VirtualButtonFunction is very simple:
Code: Select all
Function VirtualButtonFunction()
RealButtonFunction1()
EndFunctionReason for this was because sometimes I wanted to change the button function on fly. That lets say normally I wanted a button click to shoot, but then suddenly I wanted the same button to instead shoot a missile or not even do anything at all. Since Hollywood dont let you change button functions on fly, I made this call to another function, since this RealButtonFunction could be changed on fly.
Since I like to have this same functionality of changing buttons on fly in this non layer approach too, what I have in my mind is following:
I would have a table called "table_Buttons".
then when ever I want some button to exist, i would throw it to that list of buttons.
Then there be a command like ButtonsCreate() which would create all those buttons currently in that list of buttons.
If I want to change function of one button, I would first use ChangeButtonFunction() command, which would affect Teble_button.ID.function
and then I would call ButtonsCreate() again, which would first delete all currently existing button, and then create them again based upon all on that button list.
From progamming point of view this seems to me like a good solution for my problems, but I am worried will it be a problem if I continuously keep deleting and creating buttons? As example, if one button is removed (for example some game menu closed) it means all buttons would be created again after to be deleted ones are removed from list first.