So how would you recommend doing this for an indefinite amount of buttons and clones of buttons that need to be spread out through every stage?
of course, you make it as a scene and with its own script for the scene
the script of this ābuttonā scene will send signal to tell what it can do when in and out the button area
the āwhat it can doā will be determined when itās spawned/instantiated from main script
the receiver or the main script/player script will then connect the signal from each button (so when instantiated the button, you will also need to connect the signal, this if you dont do EventBus Autoload signalling) and execute movement either by function or boolean thatās always running (put in a _physics_process)
Just to be clear, I can make clones of the buttons using this method and place them separately and differently through each level?
make it as a scene or PackedScene, then reference the scene, then .instantiate() it and add_child it, then set the āwhat it can doā variable, so it has different purpose
Would this be easier to do with regular buttons? And how would regular buttons work in this, and do touchscreens react to regular buttons?
yes, but it doesnt do what touchscreenbutton do, when you pressing the button it wont count as a press, so you will need to handle it like touchscreenbutton by button down and button up signals with boolean
Is there really no way that doesnāt use scripts? Since I have to copy and paste these buttons a lot for my levels, it would be a pain if I had to mess with the scripts as well, but if thereās no other way then I guess Iāll use the control and script way.
this will need for a level generator, basically a random way to spam the button by code in a loop, rather than manually putting it one by one
when you want it to be automated , very difficult to do it without custom script. itās just the way itās
So, with the level generator, how do I place the buttons? And where do I place the level generator? Iām assuming itās itās own node, but I could be wrong.
i dont know how is your leveling, so cant tell how, if itās just randomly generated for any level, then you just need to make a button spawner code
I manually place each object and itās coordinates in each level. Although randomly generated levels do sound interesting, but also hard to program.
ok, so make and place PackedScene of the button instead of new button and new script every time itās new
click that and select the scene of button with script
So packed scene carries over everything, including script?
yes, when you created a new button and attached a script to it, and itās the button you want to duplicate, you can save it as a scene first, then next time you want to duplicate it, it will carry over as a scene
to make a scene from current node
right click the node, and select save branch as scene
Oh, ok now I understand, so I add a control node to button, add a script to the button, then I can copy and paste as a packed scene.
Ok, so now that I understand what to do a little more, after adding the control node to one button, what do I do next? Do I add a script now?
the button is basic Controlās button? if that so why need to add control as a child of this button?
No Iām still using touchscreen if that will work.
ok, so add a script to it
make it as a scene afterwards
then any changes will be done on that touchscreenbutton scene
I already had it saved as a separate scene, and in a buttons scene, but Iāve added the control node to both scenes, and a script to the one in the buttons scene. Should I make a new button scene now that I have the script and control node?