Dynamically spread out sprites.

Get help using Construct 2

Post » Tue Feb 19, 2013 7:25 am

Hey Guys,

I have a window size of 640px (X) and I have a dynamic amount of sprites that need to be evenly spread across the X coordinate.
Or a way to center these sprites and just spread them apart from each other equally while still staying within 640px.

Any ideas or questions about it?

Thanks, Dan.mcdan2013-02-19 07:29:14
B
7
S
2
Posts: 75
Reputation: 1,100

Post » Tue Feb 19, 2013 7:50 am

Here is one idea:

for each sprite:
--- set x to loopindex * 640/(sprite.count + 1)
B
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » Tue Feb 19, 2013 8:40 am

That spreads them out but starting from 0 so it's not centred.

Any other ideas to change that?
B
7
S
2
Posts: 75
Reputation: 1,100

Post » Tue Feb 19, 2013 9:02 am

I should have tested it first.

replace loopindex with (loopindex+1)
B
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » Tue Feb 19, 2013 9:09 am

You sir, are a legend.
B
7
S
2
Posts: 75
Reputation: 1,100


Return to How do I....?

Who is online

Users browsing this forum: SpartCrafter and 23 guests