Touch to Move

Hi Everyone,
How would I make a touch to move control. I want it to have if you swipe your finger up the player will jump and fall back down with gravity, swipe down and have the player duck and stay down, tap to the right and move right (but with a normal walking speed), and same with the left. Right now I have a rule that says when mouse button is down, constrain attribute self.position.X to Devices.mouse.position.X and the same with the Y. So wherever I click my character goes. How would I do the stuff that I said earlier?
Thanks
How would I make a touch to move control. I want it to have if you swipe your finger up the player will jump and fall back down with gravity, swipe down and have the player duck and stay down, tap to the right and move right (but with a normal walking speed), and same with the left. Right now I have a rule that says when mouse button is down, constrain attribute self.position.X to Devices.mouse.position.X and the same with the Y. So wherever I click my character goes. How would I do the stuff that I said earlier?
Thanks
Comments
TouchX- Real attribute
TouchY- Real attribute
Release X- Real attribute
Release y- Real attribute
Up-Real attribute
Down- Real attribute
so what you would do for the jump, is
When Touch is pressed,
Change attribute- TouchX to Mouse position X
Change Attribute- TouchY to mouse position Y
NEW RULE
When touch is released,
Change attribute- Game.releaseX to mouse position X
Change attribute- Game.releaseY to mouse position y
Change attribute Game.Up- (game.releaseY-TouchY)
Change attribute Game.Down-(game.TouchY-ReleaseY)
Then Make a new rule
when attribute up is (whatever number you want for the swipe, its the distance of the swipe) 50,
Change attribute- Motion linear y to 300
Then make a new rule
When game.down is 50(again, whatever you want the swipe to be)
Change attribute-self.height to whatever you want the height to be. You have to change the image though so it doesn't look all messed up
Then make 2 more attributes for left and right. Make them booleans
Make 2 actors. One called left and one called right. Set them up to where they each equal half of the screensize and put them on a non-scrollable layer.
So in the left actor
When touch is pressed, AND game.right is false, change attribute game.left to true
(otherwise change attribute game.left to false)
new rule----
When game.left is true, move, or change velocity to the direction and speed you want.
Make the same rules for the right actor but instead of left, use right. Just reverse the rules.
Gravity rule------
Make sure you set out a separate accelerate down rule NOT in any rules. just drag accelerate behavior on the screen. And the acceleration depends on the gravity you would like.
Hope this helps, let me know if I did anything wrong, its late here so I might be tired and confused!
- Do I make the attributes in the actor or game attributes?
- When you say the stuff to do for the jump do I make that all in the actor I want it to jump
- When you say TouchX is it game.touchX
- Change attribute Game.Up- (game.releaseY-TouchY)
Change attribute Game.Down-(game.TouchY-ReleaseY)
can you clarify this part.
Thanks
Let me know if you have any more questions