Need help aligning sprites (w random widths) with an array

Just started using Construct 2? Post your questions here

Post » Mon Feb 16, 2015 4:06 pm

Hello

I would like to create a row of sprites aligned next to each other with random widths using an array

Something like this:
Image
Where each X value defines the sprites's width

I know how to create the sprites and get the correct width from the array, but how do I align them correctly (at the end of each previous sprite) ? Is there a simple way using the same array ?
Thanks
Lunar Mission for Android & iOS
B
16
S
2
Posts: 44
Reputation: 1,365

Post » Tue Feb 17, 2015 4:11 pm

You can calculate it like this.

Image

Since you have the Width in your array, you can use those values instead of the width of the sprites, otherwise you can store the last created sprite width in a variable, together with the total width of the boxes so far. If you need to make a dynamic solution rather than a fixed one.
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest