Know which object you drop a sprite over

Get help using Construct 2

Post » Tue Aug 28, 2012 11:03 am

Hello

Maybe its already answered but i havent found it.

I have an object A which is drag and drop.

You can drop it over an object B or an object C.

How can I know the object over which you dropped A? In case is B i must do something different than C.

Thank you very much
B
3
Posts: 27
Reputation: 904

Post » Tue Aug 28, 2012 5:22 pm

Excuse me all.
I have been reading this forum but im getting a bit crazy with overlapping and layers.

I have created 3 layers with different sprites in them.
Also in one of them i have hide one sprite "under" another.

When a sprite was over another but in different layers i could touch both of them simultaneously. I fixed that using is on layer.

But in the same layer, when you have a sprite under another, toch behaviour selects both or a mix of both.

Is there a way to avoid this issue. I have tried with pick top instance but the results are a bit confused.

I was trying also to control it knowing the type of object is in touched with it. But i cant find the solution to my first question.

Thanks again to all of you.

Touching an object behind another
B
3
Posts: 27
Reputation: 904

Post » Tue Aug 28, 2012 5:57 pm

Finally i have controlled all using two auxiliary Dictionaries.

I only need to know the uid of the second object for example.

If i drop a sprite over another could i know the uid of the one dropped on?

Thank you
B
3
Posts: 27
Reputation: 904

Post » Tue Aug 28, 2012 7:35 pm

OK
Im closer

If i write the condition:
item->on dragdrop drop
item->is overlapping drawer

I can use item variables with drawer variables over which it was dropped.

But, if both of them are the same object?
item->is overlapping item

In this case i cant compare for example:
item.label = item.label

How can i write item(dropped).label=item(droppedover).label?

I continue reading anyway
Thank you
B
3
Posts: 27
Reputation: 904

Post » Tue Aug 28, 2012 7:58 pm

Ive done the following:
Create a family FA and add objects A, B and C
Create a family FB and add the same objects.

FA.On dragDrop Drop
FA Isoverlapping FB

So then I can read the information of the dropped FA.A and the over dropped FB.C

BUT family FB does not view variables of FA in the same A object for example.

Must i duplicate the information for the same object in both families, or is there a way to share variables between families?

Thank you
B
3
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 12:34 am

New try and new failure.
I have done:
familyA is overlapping FamilyB -->
                                  Set ItemOver to familyA.UID
                                  Set ItemUnder to familyB.UID
     familyA pick instance with UID ItemUnder -->
                                                    text set text to "Hola"

But the pick instance is not working and "Hola" is not prined
Please, any clue? Any help? Im starting to be out of ideas :)

I have printed the UIDs also and they are correct, so i dont know why the pick instance is not working

Thanks again to all of you.
B
3
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 2:01 am

If you could upload the capx somewhere that would be really useful for us to help!
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Thu Aug 30, 2012 8:55 am

I have simplified the project. You can find the capx here:
ethemba.com/construct2/sprites.capx

(I dont know why the objects are blinking but in the complete version is not happening so it must be something i have deleted)
The idea is:

you click in the stone, and the stone goes to the right, in the button LISTA
you click in the stick and it goes to the LISTA

Now i want to join both objects to build an axe. so if you drag and drop one over the other the one that is under the one dragged must be destroyed

In the event sheet esinventario you can find in line 7 the pick instance that its not working

Later on, instead of destroy it i will compare the Grupo variable to check if they can be combined or not. But to avoid you the plugin bitwise in this version i destroy it.
I want to have many objects and it depends where they are dropped to make something or not. Thats why i cant use mango o piedra directly. So i created two families item and pieza to make the trick.

Thank you very much
B
3
Posts: 27
Reputation: 904

Post » Thu Aug 30, 2012 3:22 pm

Seems related with this:
http://www.scirra.com/forum/about-familypick-instance-with-uid_topic53860.html

The answer must be in same place :)
I will find it
B
3
Posts: 27
Reputation: 904

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
B
3
Posts: 27
Reputation: 904

Next

Return to How do I....?

Who is online

Users browsing this forum: emoticon, MrWhizm and 16 guests