One click\touch game


#1

hi.
how do I make my character go from side to side with only one click at a time?


#2

You want a platform character to move to the clicked x-axis?
Or do you want to move the character a fixed distance?


#3

fixed distance.
the game is for android mobile.


#4

you have some option here, you can use forces, or position changes, or simulate key pressed with timers, or tweens.
you should check if player is moving, and if not, you check the position of mouse/touch and compare it to the position of the player. if x is less, move left, if x is more, move right.
i think tween is the easiest to use.

keep in mind, with tweens, it will move thru walls and everything, so you have to remove the tween, when in collusion with an impassible wall.

E:
If your level is not straight, it might be better to use timers and simulate key pressed, so that the platform behaviour manages the height differences.