Create random sprites in specific positions

Get help using Construct 2

Post » Tue Oct 15, 2013 8:42 pm


I have a family with 5 sprites and I need to create each sprite in the screen randomly, in specific positions. What's the right method to do this? Could someone give me tips. I bought Construct2 to learn about the logic process. Thanks.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue Oct 15, 2013 8:49 pm

you can have a hidden sprite then at start of layout or whenever you want your random sprite to appear put a System>create object action have x be = to hiddenspitename.x and y =hiddensprite.y to create the family at the hidden spritevolkiller7302013-10-15 20:51:36
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Tue Oct 15, 2013 9:02 pm

@volkiller730

So I need to create 5 invisible sprites for each sprite's family that I want to show?
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue Oct 15, 2013 9:16 pm

no if you mean for each family member (1familygroup) you say create familyname like i said and it will randomly spawn a object thats in that family

but if u mean like you have 5 different familys you could use instance variables on the hiddenoject to choose the family you want to create the might be a better way for this one but i cant think of any volkiller7302013-10-15 21:25:16
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Tue Oct 15, 2013 9:25 pm

Sorry. I think I was not clear enough. I've a one family with 5 sprites and I need to show all the family members in the screen (5), in different positions at the beginning of each game. The player must put the 5 sprites in order.RenatoB2013-10-15 22:02:50
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Wed Oct 16, 2013 1:54 am

This should be what you're after. Bit messy, but it will get you out of trouble. I'm sure you can clean it up, because if I did it, you'd not learn anything

https://dl.dropboxusercontent.com/u/108799982/Capx%20Demos/RandomSprite.capx
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Wed Oct 16, 2013 2:04 am

Thanks @emoaeden for the capx but could you save it in r146 version, please?
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Wed Oct 16, 2013 2:13 am

Sorry, to my knowledge you can't save a previous version. You can either update, or just install r147 in a seperate directory, just so you can get the code.

I recomend running r147, unless you are using WebGL
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Wed Oct 16, 2013 2:40 am

Thank you. I understood your solution very well.

I was giving up and using frames rather than families. The only difference in this example is that I want to swap sprites instead of dragging them to the right place.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Wed Oct 16, 2013 1:16 pm

I've only two questions about this solution:

- how can I do to prevent the correct order be randomly selected?

- if I need to use more than one family, containing other members, I'll have to create a process for each one? When I used frames, I can identify which of them would be in each location. Could I control or identify the order of the families members?

ThanksRenatoB2013-10-16 21:56:24
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests