0 Favourites

Drop area and return to original position

  • I'm with the items Drag and Drop behavior, they must be destroyed as soon as they are dropped in a specific place (each item has a place to be dropped and destroyed, if in the wrong place it will be not destroyed, it must return to the place of origin (this place that was chosen randomly so the layout starts)

    the object is dropped on top of another object, if the right object, the 2 are destroyed.

    I got 2 problems, the first and most critical is that if I click on any object and drop anywhere it is destroyed (because I do not know how to create a drop area, so wherever I drop it, it activates a particular function for drop)

    Another problem is that when I let go of the object in the wrong place, he should return to the place of origin (he not only did not back as destroy, as the problem I have quoted the above)

    can someone help me?

    tks (:

  • This would work:

    To create the drop area you could just create a sprite and check if on drag and drop end your object is overlapping the sprite.

    If the position is random at the start of the layout you should probably create two variables: startx and starty and set them to object.x and object.y at start of layout.

    if object.x is not startx or object.y is not starty

    object is not dragging

    -object set x to lerp(object.x,object.startx,0.5)

    -object set y to lerp(object.y,object.starty,0.5)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • im dumb, I used overlapping all day yesterday and today that I did not think of that, thank you :)

    regarding return to place of origin, have some difficulties with programming yet, I am learning to little, I trying to achieve here, or not warning here

    just to be clear, my random distribution of source locations is as follows:

    I have 1 sprite with 10 frames and other sprite that is 10 slots, each of the 10 frames goes into each slot at random when the game starts.

    thanks again (:

    as seen, my Ingl�s is not the best. sorry for that too

  • just add a for each and each instance will get it's own startposition in the instance variables.

    for each object

    set startx to object.x

    set starty to object.y

  • my events: imagizer.imageshack.us/v2/800x600q90/690/jkf9.png

    the option with lerp seems more interesting unable to use it yet

    line 5, is where I am trying to apply the code

    any questions regarding the code just ask that explain

    can you tell me what I'm doing wrong?

    Thank you.

  • what I think:

    if "card" in "animation - 6" is NOT overlapping "bank" it should return to the place of origin

    tks

  • you could do it without any condition.

    you will destroy the card on drop if its right, so you'd only need

    card is not dragging -

    -card.x is not startx or card.y is not starty

    --card set x to lerp(card.x, card.startx,0.5)

    --card set y to lerp(card.y,card.starty,0.5)

  • I'm really in trouble, I'm sorry again ...

    logic is clear to me, but I can not apply it to the construct,

    I do not understand where it came from the "startx" and "starty"

    and also do not know where to put "-card.x is not startx or card.y is not starty"

    doubts are well novice I imagine, but I am new in tool and am trying my best to try to understand how everything works here

    Thank you.

  • startx and starty are instance variables for the card object you should create.

    you can do this in the card properties by clicking add instance variable.

    you could have an event:

    card on created

    card set startx : card.x

    card set starty : card.y

    make an event:

    card is not dragging

    create a subevent

    system compare two values : card.startx is not card.x

    or

    system compare two values : card.starty is not card.y

    add action

    card set position :

    x - lerp(card.x, card.startx, 0.5)

    y - lerp(card.y, card.starty, 0.5)

  • oh great!!

    ------------------------

    Enjoy it

    Get free rs gold on fifa14coinsale.co.uk/ site

  • Worked perfectly, thank you (:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Original idea in this thread...
98 12,603
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
41 2,796
guannstar's avatar
guannstar
Unread hot topic
38 3,722
BarneyGumble44's avatar
BarneyGumble44