Drop area and return to original position

Get help using Construct 2

Post » Wed Jan 22, 2014 11:29 am

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 (:
B
5
Posts: 34
Reputation: 322

Post » Wed Jan 22, 2014 11:37 am

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 22, 2014 12:22 pm

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 Ingls is not the best. sorry for that too
B
5
Posts: 34
Reputation: 322

Post » Wed Jan 22, 2014 12:27 pm

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 22, 2014 1:25 pm


my events: http://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.gamarros2014-01-22 13:28:48
B
5
Posts: 34
Reputation: 322

Post » Wed Jan 22, 2014 1:32 pm

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

tks
B
5
Posts: 34
Reputation: 322

Post » Wed Jan 22, 2014 3:42 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 23, 2014 12:38 am

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.
B
5
Posts: 34
Reputation: 322

Post » Thu Jan 23, 2014 7:05 am

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 23, 2014 8:42 am

oh great!!




------------------------
Enjoy it
Get free rs gold on fifa14coinsale.co.uk/ site

B
1
Posts: 1
Reputation: 127

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 7 guests