stack objects?

Get help using Construct 2

Post » Sat Sep 28, 2013 4:40 pm


I want to stack objects. It should work like this:
There is a "plus" and a "minus" button. If you click(touch) on the "plus" button a new object should appear on top of the other. Then you click again on the "plus" button and a new object appears again on top of the other two objects. Like building a tower... If you click on the "minus" button the object should dissapear.

can u please help me?
B
9
S
5
G
1
Posts: 10
Reputation: 1,006

Post » Sat Sep 28, 2013 5:03 pm

You could use animation frame to do this mixed with instance variable. Add a variable which is called "NumberOfItems" so if you push + you increate this number and if you push - you decrease it. Then, depending on the number you show the exact frame number relative to this number.

This would work if you have a max number of items to be stackable.

However, if you really need a new object. Then still use instance variables.. if your object have NumberOfItems lets say 2 then the next object created Y position will be Object.Height * NumberOfItems (because you already have 2 objects, if your object height is 10 then the result will be 20) + Object.Height (because the base coordinates are top-left, you haveto include the object height you want to add, so now the result will be 30 for the Y position).

This formulea doesn't take spacing between objects into consideration but this could easily be added.Rushino2013-09-28 17:07:51
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Sat Sep 28, 2013 5:06 pm

thanks a lot!
B
9
S
5
G
1
Posts: 10
Reputation: 1,006

Post » Sat Sep 28, 2013 9:34 pm

The stacking of my objects with the plus button is working now,
but I haven't figured out how to delete the objects with the minus button

My capx file:
https://dl.dropboxusercontent.com/u/211639432/testforforum.capx


I would be glad if someone could help me
B
9
S
5
G
1
Posts: 10
Reputation: 1,006


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests