go to random layout

Get help using Construct 2

Post » Fri Oct 30, 2015 4:50 pm

hi everyone. how can i make that if the player collide sprite. the sprite will take him to random layout between some options?
for example: if the player in layout 1 have collision with sprite, the sprite will take him to layout : 2 or 3 or 4.
B
8
S
3
Posts: 100
Reputation: 1,023

Post » Fri Oct 30, 2015 4:55 pm

Easy. "On collision with Sprite -> go to layout by name -> choose("layoutname1","layoutname2","layoutname3"). Use as many names as you need.
B
12
S
3
Posts: 68
Reputation: 906

Post » Fri Oct 30, 2015 6:01 pm

TechnoBeaver wrote:Easy. "On collision with Sprite -> go to layout by name -> choose("layoutname1","layoutname2","layoutname3"). Use as many names as you need.



Great solution! now here is the hard way:

On collision with Sprite -> go to layout by name ->"layoutname"&int(random(1,500))

That will pick from anything named layoutname followed by a number between 0-501.

substitute 500 with the total number of layouts you have.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 30, 2015 10:16 pm

So is "choose" just an action built into Construct 2 that will always perform a random variable name in any event it's found?
B
223
S
125
G
8
Posts: 146
Reputation: 22,243

Post » Fri Oct 30, 2015 10:25 pm

YoHoho wrote:So is "choose" just an action built into Construct 2 that will always perform a random variable name in any event it's found?



Really handy if you have to choose from a bunch of string variables (text), or if you have a bunch of non-sequencial numbers to choose from.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 31, 2015 11:03 am

TechnoBeaver wrote:Easy. "On collision with Sprite -> go to layout by name -> choose("layoutname1","layoutname2","layoutname3"). Use as many names as you need.


thanks :)
B
8
S
3
Posts: 100
Reputation: 1,023


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests