How do I make something happen based on a %?

Get help using Construct 2

Post » Tue Aug 30, 2016 2:05 am

Let's say I have 60 bunnies on the screen, each colored white.

But then I click a button labeled "May turn a bunny blue". 'May' means could, so there's a chance a bunny could turn blue if I press that button.

How do I say that I want an event to have a 50% chance of occurring?

I'm not sure why all my questions involve bunnies, hopefully I made sense though.
B
25
S
10
G
1
Posts: 154
Reputation: 2,687

Post » Tue Aug 30, 2016 2:15 am

if button is clicked AND random(100) < 50 then turn the bunny blue.
or you could do
if button is clicked AND choose (0,1) = 0 then turn the bunny blue.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Tue Aug 30, 2016 2:49 am

Thanks! I assume you're talking about the Compare Two Values event. The first option works perfectly, thank you.
B
25
S
10
G
1
Posts: 154
Reputation: 2,687

Post » Mon Sep 12, 2016 3:11 pm

If I have a button, and I want it to goto a layout 4/5 times, and goto another 1/5 times, how would I go about doing that. Thanks.
B
3
Posts: 2
Reputation: 179

Post » Mon Sep 12, 2016 4:01 pm

2 layouts. 1 called "one" & 1 called "two".

Go to (layout) choose("one","one","two","one","one")
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Sep 13, 2016 3:51 am

Or using #spacedoubt method:
button is clicked
random(100)<80 --> go to layout1
else --> go to layout2
B
28
S
10
G
10
Posts: 97
Reputation: 6,584

Post » Tue Sep 13, 2016 9:35 am

AS yet another alternative, you may check this tutorial that deals with the subject.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 13 guests