How to limit direction when using touch offset?
Hi all, hope you're having a nice Christmas!
I've abandoned my logic puzzle app and have started another project, one which'll see the light of day by February/March... no really, I'm committed to this one and getting well into it.
Anyhow, small problem: I have a sliding panel; the user touches and drags it and it slides down, on release it slides back up again as I want; all good... (the Rules are based on TSB's "Touch Offset when constraining actor to the mouse" video). I want the user to be able to slide the panel down, but not up and I've been scratching my head trying to figure out how to put this in the Rules. I'm sure it's straightforward enough but I can't find the solution.
Here's the Rules, allowing the panel to slide both ways:
Rule
When touch is pressed
Change attribute self.offset y to game.Touches.Touch 1.Y - self.Position.Y
Change attribute self.drag to true
otherwise
Change attribute self.drag to false
Rule
When self.drag is true
Constrain attribute self.Position.Y to game.Touches.Touch 1.Y - self.offset y
Rule
When Any
Touch is released
touch is outside
Move To ---- slides back to closed
So to repeat, the problem is to limit it so that it can only be dragged downwards, not up at all. Any help appreciated, thanks.
----------------------------------------------
http://davidgriffinapps.co.uk/
I've abandoned my logic puzzle app and have started another project, one which'll see the light of day by February/March... no really, I'm committed to this one and getting well into it.
Anyhow, small problem: I have a sliding panel; the user touches and drags it and it slides down, on release it slides back up again as I want; all good... (the Rules are based on TSB's "Touch Offset when constraining actor to the mouse" video). I want the user to be able to slide the panel down, but not up and I've been scratching my head trying to figure out how to put this in the Rules. I'm sure it's straightforward enough but I can't find the solution.
Here's the Rules, allowing the panel to slide both ways:
Rule
When touch is pressed
Change attribute self.offset y to game.Touches.Touch 1.Y - self.Position.Y
Change attribute self.drag to true
otherwise
Change attribute self.drag to false
Rule
When self.drag is true
Constrain attribute self.Position.Y to game.Touches.Touch 1.Y - self.offset y
Rule
When Any
Touch is released
touch is outside
Move To ---- slides back to closed
So to repeat, the problem is to limit it so that it can only be dragged downwards, not up at all. Any help appreciated, thanks.
----------------------------------------------
http://davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Comments
Ace
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Try that, see what happens lol
Ace
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Ace
uptimistic: I can't seem to get into my profile to check out messages at the moment for some reason; would you mind emailing me your message please? contact@davidgriffinapps.co.uk
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Essentially:
Constrain self.y to min(initialYPosition, mouseY)
You'll need to deal with your offset but that is the basic logic.
Edit: oops! min(), not max()
Let me upload it
Ace
Firemaple's way would be more elegant if you get that up and running with the offset.
Ace
I've shied away from using max() in the past but I'll bite the bullet and experiment with your suggestion; thanks for that.
PS Uptimistik kindly emailed me another solution (Thank you Jonathan); it's great that there's "so many ways to swing a cat" here!
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Ace
Thanks to all you guys for your help, much appreciated.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps