Buttons will not drag
c_mel
Member Posts: 4
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
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
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