Fitting sprites into an area

Discussion and feedback on Construct 2

Post » Mon Dec 15, 2014 10:35 am

How can I fit a number of sprites into a given (not necessarily rectangular) area? Please see the attached pic. In my case each sprite in a given run will be the same size, but they can be different sizes on different runs. On each run I will know ahead of time how many sprites there will be. I don't want to use platform/solid or physics but open to 3rd party plugins. The appearance can be somewhat irregular as seen in the pic. Thanks.

sprite_fitting.png
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Dec 15, 2014 7:52 pm

One way would be to push the boxes away from each other and push then inside the triangle. To do it instantly you can put events 5 and 7 as sub-events of:
Start of layout
repeat 20 times

or something like that.
You do not have the required permissions to view the files attached to this post.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Dec 15, 2014 9:20 pm

That's amazing. I've tried the 'instant' method (which is what I need) and it works great. I've created 20 boxes on startup then have a one-off 'repeat 50 times' loop to get the boxes to 'settle' but it would be interesting to know an optimal number of iterations to use to provide good enough results (maybe checking when dist or edgeDist values settle, or something (guessing)). I haven't even checked out the 'box' method in the code yet. Here's my mods. Thanks again.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 32 guests