How do I disable "debug" objects?

Get help using Construct 2

Post » Thu Oct 06, 2016 2:37 pm

Hi,
I have a game with (i.e.) 1 sprite and a text object.
Each time an new sprite object instance is created, also a text object instance is created for debugging purposes.
I use those texts to display sprite's variable I need to check.
If i delete the text object from the object's list all text objects references are removed from events/actions and that's ok.
But if I later need the text object again I need to recreate it and recreate all related events.

I'm looking for a way to disable this object when I do not need it (without deleting it).
I can't simply disable the "create text object" even in the event sheet because those objects there are other references to those.
I.e I have

Select sprite where xxxxx
Select text_object where xxxxx
in the same event. And if the text is not created the event is not fired.

Is there a way to disable object so all related events/actions are toggled disabled?

Thank you!
B
12
S
5
Posts: 42
Reputation: 990

Post » Thu Oct 06, 2016 3:13 pm

Create a global variable 'debug'.
Where your debug events are for displaying debug text, add a condition if debug=1.
Then toggle debug to 0 or 1 before you start the game to enable/disable debug.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Thu Oct 06, 2016 3:23 pm

If the only effect they have is visual you can make them invisible. Either have an event that selects all and makes invisible (i.e. on tab key pressed toggle visibility) or put them all on one layer and have the whole layer invisible.

If it isn't just visible you could have an event that destroys them all every tick. Put that in a group and can toggle the group active/deactivated
ImageImageImage
B
40
S
23
G
11
Posts: 498
Reputation: 10,062

Post » Thu Oct 06, 2016 3:29 pm

Thank you plinkie! Very good sooooolution!
badmoodtaylor, your solution is also good. To switch debug of/on at runtime.
B
12
S
5
Posts: 42
Reputation: 990


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo, Exabot [Bot] and 29 guests