How do I

0 favourites
  • 10 posts
  • 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.

  • So what's the issue, or are you just looking for how to do it?

  • Gideon thanks, I would like to know how to do it.

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

  • Could u use the objects I specified in my post to explain better?

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a simple example for repositioning an object:

    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)

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

  • thanks,the solution is clear I just need to know how u came about the " setoldx to gizo.x and setoldy to gizo.y .

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