Buttons will not drag

c_melc_mel Member Posts: 4
edited November -1 in Working with GS (Mac)
I am trying to have 4 buttons on the left side of the screen constrain to the mouse when clicked. However, I have tried everything mentioned in the forums on this topic and nothing has worked thus far. I have used a global Boolean with the change attribute X and Y, but still no go. Can anyone give me step by step instructions on how to get 4 actors (buttons) to move only when clicked to a location and then when the mouse button is up go back to their original position.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    When mouse is down constrain attribute actor 1 position to touch 1, and in other wise have costrain position to wherever you want it to stay. then do the same for the rest
  • c_melc_mel Member Posts: 4
    John, have done that but the button only moves to the positions not drags with the mouse. Any thoughts?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Yes sorry didnt know you wanted to see it dragged. All you do is use interpolate attribute instead of constrain. Just replace that and keep everything i said above the same
  • MotherHooseMotherHoose Member Posts: 2,456
    okay... I get on a soapBox and preach... if you are developing for games using touch commands, don't write you code with mouse commands!

    you have 4 actors on the Left side of the screen (hopefully you have 1 actor that you placed four times in screen!)
    you want to touch/drag them to the Right side of the screen
    and when the user takes their finger off the screen, you want the actors to go back to their original position.

    double click on your actor
    on the L where color,size,position, etc. are... click the plus button... click Real for type
    name it origX
    click the plus button again ... again Real type
    name it origY

    on the code side drag in
    ChangeAttribute: (expression) origX To: (expression) self.Position.X

    ((There you have stored where the actor returns to.))

    Create a Rule in the Actor
    ===
    [Rule]
    Actor receives event touch is pressed
    ----
    ConstrainAttribute: (exp) self.Position.X To: (exp) game.Touches.Touch1.X (just click on Devices/Commands in expression editor...it will display in the correct code)
    ----
    Otherwise:
    ChangeAttribute: (exp) self.Position.X to (exp) self.origX
    ===

    This will give you a nice horizontal drag... if you want it to be vertical also, just put in the Y stuff.

    If the return to original Position is too fast...listen to @JohnPapiomitis and put a nested Rule in otherwise with if touch is released... Interpolate to origX.

    all this written out directions takes way longer than drag and click in GameSalad! ;D

    MH
  • GamersRejoiceGamersRejoice Member Posts: 817
    This will help me with what I'm trying to do, thanks MotherHoose!
  • GamersRejoiceGamersRejoice Member Posts: 817
    How would I take what you've done MotherHoose, and not allow the actor to move above or below a certain point? I only want to be able to drag the actor down in this case.
  • c_melc_mel Member Posts: 4
    Ok, put in everything you said to for the dragging portion of my problem Mother Hoose. Side note: I am actually using mouse clicks because I want this web only. Now that I have added the same code to all different four buttons, when I preview it and click the mouse button over-top of the button I want to drag it displays the last button(4th) on the page and makes the other buttons invisible. Help? Please!
  • MotherHooseMotherHoose Member Posts: 2,456
    c_mel said:
    Side note: I am actually using mouse clicks because I want this web only.

    sorry about my narrow-mindedness!

    Now that I have added the same code to all different four buttons, when I preview it and click the mouse button over-top of the button I want to drag it displays the last button(4th) on the page and makes the other buttons invisible. Help? Please!

    boy... that is weird... but so true!
    think the other buttons are just hidden behind the 4th one and all are responding to the single mouse input!

    I would suggest that you still use the touch commands even though you are creating for web/mouse interaction.
    Just as the touch commands are implemented as mouse commands in the GS Preview... they are implemented as mouse commands in the web versions... (all the online demoes are web versions and work well with the touch commands.)

    if they still seem sticky, add when touch is inside to your touch is pressed rule.

    MH
  • c_melc_mel Member Posts: 4
    Down the road a couple of days but I just wanted to say TY TY to you MotherHoose! That was the key to make it all work. Cheers!
Sign In or Register to comment.