Alleatory itens to collect

Get help using Construct 2

Post » Sun Jul 28, 2013 8:21 pm

Hi, i'm searching for tips to guide me in how can i generate itens like the coins in megajump

https://play.google.com/store/apps/details?id=com.getsetgames.megajump&hl=pt_BR

they have fixed formations that are randomly chosen. i think that i must use arrays, but i really don't know how to make this work or how to start.

tks
B
18
S
3
G
2
Posts: 20
Reputation: 1,731

Post » Sun Jul 28, 2013 9:02 pm

One way would to put each item as it's own animation in the same sprite.
then when you startup the level you can change the sprites animation at random.

Set the animation to:
TokenAt("AnimationName1,AnimationName2,AnimationName3"),random(3),",")

this grabs one of the 3 names at random, using the comma as a separator.

Then on collision with the object you can check to see what animation was playing.
B
222
S
59
G
32
Posts: 901
Reputation: 39,213

Post » Sun Jul 28, 2013 10:24 pm

you can:
1.- create a couple (i.e.3) 2-dimensional arrays (x,y), and
2.- OnStartOfLayout: Set "varStartingArray" to: Choose ("array1, array2, array3"), then
3.- Use a loop that places the items according to the chosen array coordinates.
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Mon Jul 29, 2013 12:31 pm

thanks for both i'm working now and when i finish the mecanics i'will share some capx
B
18
S
3
G
2
Posts: 20
Reputation: 1,731


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests