How do I space objects evenly across the screen?

Get help using Construct 2

Post » Mon Sep 14, 2015 9:58 pm

Just wondering if anyone can help me with this:

I have 16 objects on the screen, which are all vertical lines. They can all be turned on and off.

When some of them are turned off I need them to all expand to fill the same amount of space equally, so when there is just one left it fills the whole screen, when there are two they take up 50% each etc.

To get them to be the right width, I've just divided the screen size by number of objects, but I'm having a much harder time getting them to go in the right place, because they can be turned on/off in any order. What I really need is the equivalent to the "space horizontally" thing in the editor.

Any ideas? Thanks!
B
6
S
1
Posts: 50
Reputation: 500

Post » Mon Sep 14, 2015 10:50 pm

working atm can you send the file?
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

Post » Tue Sep 15, 2015 12:48 am

If their hot spot is to the left you could do this:

global number num=0

sprite is on
--- set num to sprite.pickedcount

sprite is on
for each sprite
--- set x to 640/num*loopindex
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Tue Sep 15, 2015 10:31 am

Wow thanks, that is exactly what I wanted, worked perfectly! Awesome
B
6
S
1
Posts: 50
Reputation: 500


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Jackriduk, kiki4construct, Yahoo [Bot] and 30 guests