How do I

Get help using Construct 2

Post » Sat Jul 25, 2015 9:56 am

Hello guys, I thank everyone who has proffered solutions to my previous post. I still need to solve an issue. I av created a drag and drop object (gizo) which I made to destroy when dragged to collide with another object( Hut1) . I created another object (Hut2) , i want gizo to be repelled back to its picked position when it is dragged to collide with Hut2. Thanks in anticipation for your help.
B
6
S
1
Posts: 44
Reputation: 484

Post » Sat Jul 25, 2015 12:53 pm

So what's the issue, or are you just looking for how to do it?
B
10
S
1
Posts: 72
Reputation: 1,014

Post » Sat Jul 25, 2015 1:02 pm

@gideon thanks, I would like to know how to do it.
B
6
S
1
Posts: 44
Reputation: 484

Post » Sat Jul 25, 2015 1:09 pm

There are so many ways to do this, giving the one you'd like would be pretty hard..

First thing you would do is change/set a (boolean) instance variable on collision.
set drag and drop disabled
and set the movement you want based on the state of the instance variable.
You can re-enable the drag and drop and change/set the instance variable back, when the original position is reached.
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 » Sat Jul 25, 2015 2:45 pm

@littlestain. Could u use the objects I specified in my post to explain better?
B
6
S
1
Posts: 44
Reputation: 484

Post » Sat Jul 25, 2015 3:19 pm

To make something go back to a previous position you need to store those coordinates somehow. Usually you give the object two variables for this (oldX, oldY), when you click the object you want to drag, you store the current position in oldX, oldY and when you drag gizo to hut2, you reset the object position by setting the current X,Y position to the oldX, oldY variables.
B
20
S
8
G
4
Posts: 195
Reputation: 3,555

Post » Sat Jul 25, 2015 4:41 pm

@eliastfros thanks, but I don't quite understand wat u mean by oldx and oldy, but I already set 2 variable for gizo. variable 1 boolean TRUE. and variable 2 FALSE. gizo just move under hut2 instead of colliding with it. please help me out.
B
6
S
1
Posts: 44
Reputation: 484

Post » Sat Jul 25, 2015 5:12 pm

Here's a simple example for repositioning an object: Image

Now if you want to move the object smoothly back to it's position it's a bit more complicated than that because you need to make sure that gizo doesn't collide with anything on the way (you disable collision until gizo reaches oldX and oldY, I think that was what LittleStain was getting at in his post).

EDIT: Oh and that gizo is moving under hut2 is a zorder issue, you may want to change the zorder of the objects if you want gizo to appear ontop of hut2. (right-click -> Z Order)
Last edited by eliasfrost on Sat Jul 25, 2015 5:20 pm, edited 1 time in total.
B
20
S
8
G
4
Posts: 195
Reputation: 3,555

Post » Sat Jul 25, 2015 5:14 pm

@joeb12

You would probably get far better assistance if you posted your current .capx. It makes it much easier to see both the problem and possible solution.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,414
Reputation: 59,512

Post » Sat Jul 25, 2015 7:03 pm

@eliastfrost thanks,the solution is clear I just need to know how u came about the " setoldx to gizo.x and setoldy to gizo.y .
B
6
S
1
Posts: 44
Reputation: 484


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests