Dragging and dropping an actor onto another

RastaRiseRastaRise Member Posts: 52
edited November -1 in Working with GS (Mac)
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

  • chosenonestudioschosenonestudios Member Posts: 1,714
    when game."placed" is true constrain self.position x to other objects x constrain self.position y to other objects y
  • RastaRiseRastaRise Member Posts: 52
    I'm new to this...
    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?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Now the object you want it to stay on top of, you'll have to add this:

    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!
  • RastaRiseRastaRise Member Posts: 52
    I get what you said but i cant seem to get it to work. Does anyone have a method for this? or could someone make a sample for me?
  • RastaRiseRastaRise Member Posts: 52
    to add more detail....

    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.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    alright add a rule that says:

    when touch is released:

    when object is overlapping or colliding with sbox:

    insert constrains here (use the ones on my previous post)
  • RastaRiseRastaRise Member Posts: 52
    Ok, I think I can get it and this is my last problem.

    where you said game.object x and y, I dont see sbox anywhere. I know im a noob but I really appreciate the help
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Ok put this in sbox:

    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! :D

    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
  • RastaRiseRastaRise Member Posts: 52
    thanks so much man it worked!
  • chosenonestudioschosenonestudios Member Posts: 1,714
    rastar said:
    thanks so much man it worked!

    Yep, No Prob! :D
Sign In or Register to comment.