Hello All,
As part of my ongoing development on my upcoming game I am trying to work out some touch controls. The game is a platformer and has the following features that will require some type of UI touchscreen control scheme:
Basic Platform Movement (Left, Right, Jump)
Fall Through (Press Down to fall through jumpthrough platforms)
Run
Double Jump
Wall Jump
Change Form (There are three different modes/forms the character learns during the game)
Action/Attack
Most of this is for the most part easy to do, the issue I am running into here is really on implementing the run option. When using the keyboard I simply assign a button down event to double the maxSpeed of the character and change the animation to the Run animation. However, I am finding it harder to do with a touchscreen control setup. I do not want the player to have to hold down multiple buttons as that is very difficult on a touchscreen game. My thoughts are to do one of the following:
1. Implement a double tap on the left/right movement buttons that starts the run. (I am trying to find a good way to do this using a state variable and a timer).
2. Implement a toggle button on the screen that if it is pressed while moving it will double the walk speed and change to the run animation. This one has been a bit difficult.
The difficulty in both of these seems to stem from having to use the on touch simulate platform left/right events to get the initial movement working. I believe this is overriding everything else. What I tried at this point is having a global variable called "running". Normally this is set to 0. If they touch the run button while they are walking (Holding the left/right touchscreen buttons) it should set the walk speed and animation accordingly however this does not ever seem to work.
My assumption is that since the touch left/right button events are written as "Is Touching button > Simulate Platform Pressing Right" that it is overriding anything else I try to do to the movement. Below are some of the various schemes I have tried while working on this, none of them seem to do what I want.
The base movement updated with touch events and keying off the running variable:
<img src="http://dl.dropboxusercontent.com/u/10285716/ConstructSampleScreenshots/MovementTouchUpdate.png" border="0" />
The touch events
<img src="http://dl.dropboxusercontent.com/u/10285716/ConstructSampleScreenshots/PlatformTouchEvents1.png" border="0" />
And Another option trying to detect when they let go of the left/right buttons to deactivate the run:
<img src="http://dl.dropboxusercontent.com/u/10285716/ConstructSampleScreenshots/DetectReleaseOfTouch.png" border="0" />
ALso here the updated double jump logic to take touch into account as well, this works just fine it is just to illustrate how I am integrating keyboard and touch into the same project:
<img src="http://dl.dropboxusercontent.com/u/10285716/ConstructSampleScreenshots/TouchDoubleJumpLogic.png" border="0" />
The jumping, double jumping and even the wall jumping all work as expected with touch, but the run does not work at all. Once in awhile I will see the character start the first frame of the run animation when the run button is touched while walking, but that is as far as it goes. It reverts right back to regular speed and walk animation. The various variables used in the events are pretty self explanatory based on their names, but if anyone needs clarification just let me know.
Thanks,
James