disable all instances when one is clicked

Get help using Construct 2

Post » Sat Oct 22, 2011 1:38 pm

Hello,

I have 9 instances of a button. I want to disable them all when one of them is clicked. However, when I add "system for each..." to the button click event, only the instance which has been clicked gets disabled...
How can I loop through all instances of an object?

Thanks,

Jeroen
B
5
G
2
Posts: 10
Reputation: 1,145

Post » Sat Oct 22, 2011 1:50 pm

In the object-clicked event, only the clicked object is picked, so all the actions will only refer to that object. To work around that you need to do the work in a separate event.

You could set a local variable to "1" in that event, and in the next event if it is "1" do the action and it'll apply to all the objects.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Oct 22, 2011 1:53 pm

http://dl.dropbox.com/u/36472942/construct/forumhelp/DisableButtons.capx
Indeed, "for each" loop will only act on the currently picked object (taht is to say only the instance that was clicked in your case).

The idea is to "delay" the command to the next tick.


EDIT: Ninja'd by Ash while I was doing the example Kyatric2011-10-22 13:54:39
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Oct 22, 2011 2:04 pm

Thanks for the quick reply. Now I understand how to write and call 'functions' in general.

Jeroen
B
5
G
2
Posts: 10
Reputation: 1,145


Return to How do I....?

Who is online

Users browsing this forum: abdalghani, Kagubro and 22 guests