Dragging and dropping an actor onto another
RastaRise
Member Posts: 52
I got the drag and dropping part to work but i need help with getting the actor to stay on top of another actor. I have a box and when the game starts it accelerates down the screen. I want to be able to drag the actor and place it on top of another actor and have it stay there. Could anyone help with this? When i drag the box onto the other actor it just bounces off and there are no collision attributes...
Comments
I have set up the rule and made a new attribute "placed" and have set up the constrain attribute self.Position.X and self.Position.Y but how would i go about constraining them to the other objects?
constrain attribute: game.object x to self.position x
constrain attribute: game.object y to self.position y
When you set your object down..... change game."placed" to true.....
And then for the object that you want it to stay on, add this:
When game.placed is true:
constrain attribute: self.position x to game.object x
constrain attribute: self.position y to game.object y
Hope this helps!
Cheers!
P.S. Sorry about earlier I was kinda in a bad mood because I couldn't get something to work haha, but it works now!
Good Luck!
Oh yeah, and welcome to the community!
I have two actors
"shape2" - actor being put on top of sbox
"sbox" - actor shape2 is being put onto
I added the drag and drop movement so when i touch and hold "shape2" it drags with my finger. I want to be able to release "shape2" on top of "sbox" and have it stay on top of "sbox" when I release "shape2" on top of it.
when touch is released:
when object is overlapping or colliding with sbox:
insert constrains here (use the ones on my previous post)
where you said game.object x and y, I dont see sbox anywhere. I know im a noob but I really appreciate the help
constrain attribute: game.sbox x to self.position x
constrain attribute: game.sbox y to self.position y
And put this in shape 2
when touch is released:
when object is overlapping or colliding with sbox:
constrain attribute: self.position x to game.sbox x
constrain attribute: self.position y to game.sbox y
(Game.sbox x and Game.sbox y are attributes that you will have to make)
(To do this go into your scene and hit attributes then hit the little plus button and make them integers)
Hope this helps!
Good Luck!
I'm going to bed now, I have to go to work in 4 hours... if your still having problems just post on this thread and I'll get back to you! night