One way to do it would be to put a large button over the entire stage and keep track of your players X and Y locations. Then when the player touches the screen you could compare the players X/Y location with the X/Y of the touch location and move the player in the correct direction.
I'm just typing that off the top of my head, without testing it, but it should work.
when mouse positon x is greater than 160 and pressed change game.right to true when mouse position x is less than 160 and pressed change game.left to true
I don't get what you want exactly. do you have 2 actors in the screen and then when you press the right one only the right one moves? and when you press the left one the left one moves right?
or do you have 1 actor and when you touch outside of the actor on the right side it moves to the right?
can you try to explain better ?
gyroscopeI am here.Member, Sous Chef, PROPosts: 6,598
Hi @GM_Pandagames Similar to what the other guys said, but with a bit more detail (although still a rough idea):
Make a real attribute, called PosX.
Bring an actor onto your screen, make it the size of the screen, call it Back. Put the actor you want to move onto the screen. Change the value of PosX to its X position. In the Rules of the moving actor, put:
Constrain Attribute self.Position.X to PosX
Now in the Rules of the Back actor, put:
Rule: When touch is pressed Rule: ---nested in above--When game.Touches.Touch 1.X > scene.PosX ---your moving rules to the right for your moving actor, depending on the method of moving chosen Otherwise ---your moving rules to the left for your moving actor, depending on the method of moving chosen
Comments
I'm just typing that off the top of my head, without testing it, but it should work.
when mouse position x is less than 160 and pressed change game.left to true
This should work
or do you have 1 actor and when you touch outside of the actor on the right side it moves to the right?
can you try to explain better ?
Hi @GM_Pandagames Similar to what the other guys said, but with a bit more detail (although still a rough idea):
Make a real attribute, called PosX.
Bring an actor onto your screen, make it the size of the screen, call it Back.
Put the actor you want to move onto the screen. Change the value of PosX to its X position. In the Rules of the moving actor, put:
Constrain Attribute self.Position.X to PosX
Now in the Rules of the Back actor, put:
Rule: When touch is pressed
Rule: ---nested in above--When game.Touches.Touch 1.X > scene.PosX
---your moving rules to the right for your moving actor, depending on the method of moving chosen
Otherwise
---your moving rules to the left for your moving actor, depending on the method of moving chosen
THat should give you a good start.
I changed it up from my description above so there are no constraints.