Know which object you drop a sprite over

0 favourites
  • 15 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello

    Maybe its already answered but i haven�t 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

  • Excuse me all.

    I have been reading this forum but i�m 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 can�t find the solution to my first question.

    Thanks again to all of you.

    Touching an object behind another

  • 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

  • OK

    I�m 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 can�t compare for example:

    item.label = item.label

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

    I continue reading anyway

    Thank you

  • I?ve 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 <img src="smileys/smiley19.gif" border="0" align="middle" /> 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

  • 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 <img src="smileys/smiley6.gif" border="0" align="middle" />

    Please, any clue? Any help? I�m 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.

  • If you could upload the capx somewhere that would be really useful for us to help!

  • I have simplified the project. You can find the capx here:

    ethemba.com/construct2/sprites.capx

    (I don?t 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 can?t use mango o piedra directly. So i created two families item and pieza to make the trick.

    Thank you very much

  • Seems related with this:

    scirra.com/forum/about-familypick-instance-with-uid_topic53860.html

    The answer must be in same place :)

    I will find it

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don�t know what to do.

    As i can�t access instance variables from an object from different families, and i can�t 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 can�t select another object of the same type.

    I�m able to make changes with the object dragged, but i can�t select the other object. The uid is correct but its impossible to select it.

    And i�m 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 don�t have more ideas <img src="smileys/smiley19.gif" border="0" align="middle" />

    Thanks to all

  • 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 i?m exhausted of this matter <img src="smileys/smiley17.gif" border="0" align="middle" />

    I hope this help someone in the future

    I will wait with this solution until subfamilies are available <img src="smileys/smiley20.gif" border="0" align="middle" />

    Thanks to all

  • 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.

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

  • 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 i�m 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.

  • Thank you Nimtrix

    It�s 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.

    I�m 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)