Know which object you drop a sprite over

Get help using Construct 2

Post » Thu Aug 30, 2012 4:08 pm

I dont know what to do.
As i cant access instance variables from an object from different families, and i cant create subfamilies (not still at least :) ) my only option was to save uid and select the object with it.

But it seems that when the first object is picked during the drag and drop movement, you cant select another object of the same type.

Im able to make changes with the object dragged, but i cant select the other object. The uid is correct but its impossible to select it.

And im unable to find the clue. Sorry.

The only thing i could test finally (before leave this for impossible) is to use a variable and try to do the operations outside the first if (event)

I dont have more ideas
Thanks to all
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 4:22 pm

It works :)

So finally what i have done is:
item on drag&drop drop
is overlapping Pieza --> set itemdropped to item.UID
                           set itemdropover to Pieza.UID
                           set changespending to 1

system every tick
system CambiosPendientes=1
      item pick instance with UID itemdropped --> actions

      item pick instance with UID itemUnder --> actions

Maybe is another way but im exhausted of this matter

I hope this help someone in the future

I will wait with this solution until subfamilies are available

Thanks to all
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 4:38 pm

agarciamuntion, the capx does not run very well for me. As you said, the sprites blink, and then they eventually disappear.

Would it be possible for you to create a new project with simple graphics and with events showing only the mechanic you are trying to achieve?

EDIT: Never mind, i didn't see your last post. Wastrel2012-08-30 16:40:10
Don't see the fnords and they won't eat you!
Posts: 326
Reputation: 11,986

Post » Thu Aug 30, 2012 4:45 pm

I see you've found what you're looking for, but I had already started so here's an example anyway: DragDropPicking.capx (r101)
Posts: 903
Reputation: 8,452

Post » Thu Aug 30, 2012 11:12 pm

Thank you.
Sorry i was enjoying my solution :)
Nimtrix: Thank you very much. I am going to download r101 as i was using the latest stable r95, and i will have a look because im not sure of my solution. It works but its really complicated to follow with many variables to control.
Wastrel: I promise i will upload a fully operational example of the solution. MAybe i can help someone one day. I prepare this one really fast because i was a bit desperate this morning. I have been two days until i realice that when you are in a loop with an instance picked, you cannot pick another one of the same family. After that i needed to restructure all the conditions and set many variables to store UIDs to change between instances.

Thank you very much.
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 11:28 pm

Thank you Nimtrix
Its a great solution. My problem was that the objects where both of the same type and family.

I have a Dropspot with a Item over it, for example a rope.
In another i have two sticks, another item
In another i have a sprite with a fish

So if you drop the rope over the sticks they are joined, so rope is destroyed and the sticks became something new.
But if you drop the rope over the fish nothing happens.

Im not interested in the DropSpot where the item is. I needed to know the item over which the item drops over.

So finally i have
item is overlapping dropspot
item pick nearest to (Drag.X, Drag.Y)
which is really confuse :)

Tomorrow i will prepare an example :).

Thanks for your time and interest.
Posts: 27
Reputation: 904


Return to How do I....?

Who is online

Users browsing this forum: irina and 24 guests