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
8
S
2
Posts: 75
Reputation: 1,125

Post » Tue Feb 19, 2013 7:50 am

Here is one idea:

for each sprite:
--- set x to loopindex * 640/(sprite.count + 1)
B
85
S
27
G
78
Posts: 5,013
Reputation: 54,260

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
8
S
2
Posts: 75
Reputation: 1,125

Post » Tue Feb 19, 2013 9:02 am

I should have tested it first.

replace loopindex with (loopindex+1)
B
85
S
27
G
78
Posts: 5,013
Reputation: 54,260

Post » Tue Feb 19, 2013 9:09 am

You sir, are a legend.
B
8
S
2
Posts: 75
Reputation: 1,125


Return to How do I....?

Who is online

Users browsing this forum: ling200916, ridhoemgl, vext and 7 guests