How do I move an object to a free space?

Get help using Construct 2

Post » Thu Feb 12, 2015 12:19 pm

Hey there,
In my game you can pick up items, and on top of the screen you will be shown what items you have collected so far.
But I'm strugglin with making a system that checks if there already is an icon on top of the screen, so not all the icons are stacked on top of eachother.
I made a quick comic to show what I want to achieve:
Image

All the items can be picked up in a different order, so the one picked up first will be put on the most right side of the screen, the second one picked up to the left of that one and so on.

I tried multiple ways, including little boxes, with image frames according to the icon. But that didn't really work and seemed like a lot of work for such a small feature.

What I have now is a little icon border that checks if the space if free or not, but I don't know how to tell to move to the next icon border when the space is not free, and to the next iconborder is that one isnt free aswell.

I really hope there is an easier way :)
B
8
S
4
Posts: 120
Reputation: 1,266

Post » Thu Feb 12, 2015 12:57 pm

Can you create a variable for that, which will keep track how many objects are already there?
Which will get +1 when you put something there and -1 when you remove it?
And then when you add next object there you can position it with that variable, like (new object position.X = default position X - (variable * desired distance))
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Thu Feb 12, 2015 2:16 pm

@razorMonkey Thanks a lot! it works perfectly now.
Image
B
8
S
4
Posts: 120
Reputation: 1,266


Return to How do I....?

Who is online

Users browsing this forum: ChesVCF, SoldjahBoy and 4 guests