How do I assign a random boolean to a set of objects?

Just started using Construct 2? Post your questions here

Post » Fri Feb 27, 2015 11:39 pm

I can a set of Spot objects which have a boolean instance variable of isActive.

Capture.JPG


Once a second I want random spots to toggle this state (as opposed to above, where all are toggles every second).

I've seen the randomnumber(0,1) method, but I can I convert the number into true or false.?
You do not have the required permissions to view the files attached to this post.
Last edited by BanksySan on Fri Feb 27, 2015 11:55 pm, edited 1 time in total.
B
5
Posts: 10
Reputation: 250

Post » Fri Feb 27, 2015 11:53 pm

There are two options as I see it.

1. Change isActive to a number rather than a boolean and just use 0 and 1 to represent false and true, respectively.

2. Add another condition to event 7 along these lines:

Code: Select all
System: Compare two values: choose(0, 1) = 1

Which will choose randomly from 0 and 1, if the value is 1, then the condition is true and your Spot's isActive boolean will toggle.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Sat Feb 28, 2015 12:11 am

Cheers Linkman,

I did a little bit before seeing your post. What I have now is making the isActive random, now however, gradually all the spots get isActive set to [i]true[i]. It takes about ten seconds.

event-sheet-with-randomsJPG.JPG
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 10
Reputation: 250


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest