How do I Shuffle Sprites On The Grid

Get help using Construct 2

Post » Wed Jan 07, 2015 1:44 am

Hello,

I have 1 sprite with 9 copies on the layer with UIDs 0-8. They are displaying on the Grid, each grid is of width 200.
I want to shuffle their positions on the start of the layout.

Please let me know how can I do it.
B
7
Posts: 41
Reputation: 359

Post » Wed Jan 07, 2015 2:25 am

offhand, a foreach for the sprites, and the position being set to some x of floor(random(3)) * 200, and y of same, offset from your origin x,y position for the grid. Tweak as necessary.

EDIT: Umm, yeah, don't do this. Follow Magistross' reply below, which is what I intended but somehow completely spaced. Blaming Canada.
Last edited by aerger on Wed Jan 07, 2015 7:47 pm, edited 1 time in total.
B
31
S
6
G
3
Posts: 22
Reputation: 4,764

Post » Wed Jan 07, 2015 2:09 pm

@aerger Thank you, I will try it :)
B
7
Posts: 41
Reputation: 359

Post » Wed Jan 07, 2015 2:43 pm

You ought to remove the random element from the positionning events, otherwise you'll most likely end up with sprites occupying the same spot. What you need is random picking and fixed positionning. Here's an example.
You do not have the required permissions to view the files attached to this post.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Wed Jan 07, 2015 4:30 pm

@Magistross that is brilliant thank you very much. It does exactly what I was trying to do.
B
7
Posts: 41
Reputation: 359

Post » Wed Jan 07, 2015 7:07 pm

When I went to reply, random picking what I was thinking/planning, but when I wrote it out, something else came out. It was late. :P Good catch.
B
31
S
6
G
3
Posts: 22
Reputation: 4,764


Return to How do I....?

Who is online

Users browsing this forum: SputnikCZ and 3 guests