How do I...Arrange/Distribute Sprites Evenly?

Get help using Construct 2

Post » Wed Jan 17, 2018 5:59 pm

Hey all, I have a quick question. I'm trying to make a card game that will have a hand of cards with between 0 and...let's say 30 cards. The hands would probably average between 4 and 6 cards in it at any given time. I am familiar with a wonderful little tool in Adobe Illustrator that allows one to select several objects and arrange them evenly in an area, much like this:

I start with five randomly-placed squares:
Image

And then I use the "Horizontal Align Center" command:
Image

And then i use the "Vertical Distribute Center" command:
Image

This last step is what I'm after. I would love to have events that count the number of cards in hand and vertically distribute them so that they are evenly spaced and easy to read. Is there an event action that can make this happen? Thanks for your help!
B
6
Posts: 3
Reputation: 256

Post » Wed Jan 17, 2018 6:11 pm

Hey @Methuselah!

This may be not exactly what you want, but I had this capx with card game related functions. One of them organizes the player's hand. It might help you to make your own.

https://www.dropbox.com/s/anbtxlrdk2n1l ... .capx?dl=1

Hope this helps. Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 722
Reputation: 4,026

Post » Wed Jan 17, 2018 7:43 pm

To arrange the sprites like in your example you can do this:

for each sprite
--- set position to (lerp(100, 300, loopindex/(Sprite.count-1)), 400)

100 if the leftmost x and 300 is the rightmost. 400 is the y.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

Post » Thu Jan 18, 2018 5:32 am

Also, I got my "horizontal" and "vertical" backwards in my OP, so oops.

But thank you both! @R0J0hound, that is exactly the thing I was looking for. @brunopalermo, your example is totally what I want to have in my game. Thanks again!
B
6
Posts: 3
Reputation: 256


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests