Laying out objects proportionally.

Get help using Construct 2

Post » Sat Nov 30, 2013 9:11 am

Hi Guys,
does anyone know a way to lay out enemy sprites proportionally on the screen along X?
I meant this:
1. I'm picking up number of enemies at random(1,10)
2. They should appear along one line (the same Y)
3. Now if there is one enemy it should appear in the middle of the screen
If two enemies than in 1/4 and 3/4 of the screen width (X).
And the same way up to 10 enemies.

Well I figure it out using X,Y,Z array storing position but I'm wondering if there is easier way using some algorithm ??

How would you approach the problem ?

Thanks
E
B
6
S
1
G
1
Posts: 20
Reputation: 780

Post » Sat Nov 30, 2013 9:20 am

would 2 enemies not need to be at 1/3 and 2/3?

that would seem more logical.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Nov 30, 2013 9:26 am

x Position of object 'n' = (Width of screen / Total number of objects + 1) * n

I think that's right??!!
B
6
Posts: 23
Reputation: 421

Post » Sat Nov 30, 2013 9:27 am

(screenwidth/(numberofenemies+1))*multiplier

then you should add 1 to the multiplier for each enemy to get the x-coordinates.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Nov 30, 2013 10:33 am

works like a charm !

Thank you all
E
B
6
S
1
G
1
Posts: 20
Reputation: 780


Return to How do I....?

Who is online

Users browsing this forum: MrSkailo and 23 guests