Page 1 of 1

How do I space objects evenly across the screen?

PostPosted: Mon Sep 14, 2015 9:58 pm
by shortwave
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!

Re: How do I space objects evenly across the screen?

PostPosted: Mon Sep 14, 2015 10:50 pm
by CBelle
working atm can you send the file?

Re: How do I space objects evenly across the screen?

PostPosted: Tue Sep 15, 2015 12:48 am
by R0J0hound
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

Re: How do I space objects evenly across the screen?

PostPosted: Tue Sep 15, 2015 10:31 am
by shortwave
Wow thanks, that is exactly what I wanted, worked perfectly! Awesome