I'm new to C2, so I apologize if this question has a very simple, obvious answer I should have found in my searching and tutorial-reading!
I'm trying to make a create/destroy button which will create an object if there is no objectsprite on the screen and destroy the object if the objectsprite is onscreen.
Basically a show/hide button; click once and the object appears, click again and it disappears, click a third time and it appears again, etc.
Here's what I've tried:
To create the object:
------------------------------------------
On mouse click on buttonsprite
AND
buttonsprite variable1=0 (which is default value)
System create objectsprite
buttonsprite add 1 to variable1
-----------------------------------------------
To destroy the object:
------------------------------------------------
On mouse click on buttonsprite
AND
buttonsprite variable1=1 (which shows it's been clicked once, so the objectsprite has been created)
objectsprite destroy
buttonsprite set variable1 to 0 (ready to create object again on next mouse click)
-----------------------------------------------------
In my head this logic should work, but onscreen...nothing happens. Is the button click instantly setting the variable to 1, thus also triggering the destroy event with that initial button click?
I have searched for a solution to this but either I haven't found it or am too dense to realize the answer is staring in my face. Any suggestions or links to relevant tutorials would be greatly appreciated! Thanks!