How do I make choose random layout?

Get help using Construct 2

Post » Thu Jul 24, 2014 6:23 am

anyone can help?

Thanks
~Everyone can make GAMEs~
B
58
S
12
G
1
Posts: 414
Reputation: 5,961

Post » Thu Jul 24, 2014 8:15 am

I don't know if there is a better way but you can try generating random global variable value, and for each value, you can use "go to layout" like this:

System -> On start of layout
System -> Set Value -> your variable, round(random(1,yourlayoutcount))

System -> Compare variable -> your variable = 5
System -> Go to layout -> 5
B
18
S
2
G
1
Posts: 67
Reputation: 1,339

Post » Thu Jul 24, 2014 8:43 am

Something like:
Ensure Layouts are numbered sequentially, such as 'Layout1', 'Layout2' etc, then

System Go to Layout "Layout"& int(random(5)+1)
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,555
Reputation: 60,454

Post » Thu Jul 24, 2014 10:53 am

@Zenox98 what the function of >> int(random(5)+1 <<
can you describe it please?

System -> Set Value -> your variable, round(random(1,yourlayoutcount))
@Xenovia what the meaning of yourlayoutcount ??
~Everyone can make GAMEs~
B
58
S
12
G
1
Posts: 414
Reputation: 5,961

Post » Thu Jul 24, 2014 11:11 am

Hardty wrote:@Zenox98 what the function of >> int(random(5)+1 <<
can you describe it please?

System -> Set Value -> your variable, round(random(1,yourlayoutcount))
@Xenovia what the meaning of yourlayoutcount ??

int(x) - Convert the float or text x to an integer (whole number).

Then, random(5)+1 will add 1 or 5 number to "Layout" string, but that's not working, " " is missed, the correct string is
Go to Layout (by name) > "Layout"&" "&floor(random(0,6))
or
Go to Layout (by name) > "Layout"&" "&int(random(5)+1)
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Thu Jul 24, 2014 11:28 am

example.capx

Here, a little capx to show what i mean, run layout 1 and refresh several times, you will see that a random layout from 1 to 5 choosed.
You do not have the required permissions to view the files attached to this post.
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Thu Jul 24, 2014 11:46 am

Thankss man! :D
~Everyone can make GAMEs~
B
58
S
12
G
1
Posts: 414
Reputation: 5,961


Return to How do I....?

Who is online

Users browsing this forum: Seruza and 5 guests