How do I apply an action to specific instances only?

Discussion and feedback on Construct 2

Post » Sat Mar 12, 2011 3:09 pm

Newbie to Construct2 as well as game programming. Making a small game for my blog so people are entertained in between posts. Found Construct2 yesterday and I have got the basic scaffolding for my game up. I've run into a small problem though: I've got some cockroach instances but only want randomly selected instances of the cockroach sprite to move around at one time. Any idea how I can do this?
B
1
G
1
Posts: 3
Reputation: 431

Post » Sat Mar 12, 2011 3:54 pm

The fundamental way the event system works is that you use conditions to pick certain instances, then the actions only run on those instances. So to apply an action to a specific instance, you make a condition that chooses the instance to pick.

In this case, it sounds like you want 'pick nth' (under system). There was a 'pick random instance' condition in 0.x, but it hasn't made it to C2 yet - so try pick nth and enter random(Sprite.count) as the instance to pick.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sat Mar 12, 2011 4:45 pm

Thanks. I saw the condition but it picks only one instance. Is there a way I can pick up multiple instances? I saw a For loop which I would try to use with the pick nth condition but not sure how I can tie the two together.
B
1
G
1
Posts: 3
Reputation: 431

Post » Sat Mar 12, 2011 4:56 pm

You could tack on a 'Repeat N times' above it?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sat Mar 12, 2011 5:03 pm

Thanks, I'll try that out : )
B
1
G
1
Posts: 3
Reputation: 431


Return to Construct 2 General

Who is online

Users browsing this forum: Mirlas, wrighthill and 14 guests