Platform Movement with Touch Controls Question

  • 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

  • I would prefer a double tap option on the walk buttons to toggle running, but that has not been as easy as I thought. I used some examples from the forums but they are more generic and allow touch anywhere on the screen instead of double tapping on a specific control. If anyone has implemented walking/running on platform with touch events please let me know, I would also love a slide/dash option as well but that is not required for this game, just nice to have.

  • would splitting the move "zone" into two sections not work?...

    Imagine a virtual D pad in this case the player is going right

    with the player sliding the thumb more to the right of the D pad to invoke run and back to the left slightly to revert back to walk?...double tapping never feels reliable enough to me...

    Stuff like this really shows the deficiency of touch input for gaming...

  • I would say do something similar to

    On Touch Release RightButton

    -- set runright 1

    -- wait 1

    -- set runright = 0

    --if player.isRunning = 1

    --- player.isRunning = 0

    OnTouch Pressed RightButton

    --if runright = 0

    ---- set player speed to normal, walk animation, player.moveright = 1

    --if runright = 1

    ---- set player speed to run, do run animation, player.moveright = 2

    Is InTouch rightbutton

    -- if player.moveright = 1

    ---- continue walking

    -- id player.moveright = 2

    ---- continue running

    also you could just make an analog based control. make it wide so that the player has good degree of difference between walking and running.

    Then

    if analogstick.X > 0 and < 80% then do walk stuff

    if analogstick.X > 80 then do run stuff

  • jayderyu I can't find a touch release or touch end event that lets you specify which object is being released. The end touch events seem to be any touch, or nth touch. Not specific to an object which is what I really need in this case. Then I could do something like on touch end, start timer, and if touched again before the timer runs out trigger the run.

    I will try to implement as close to what you have suggested as I can and see how far that gets me.

  • How about something like this for the touch end?

    TouchRelease.capx (r134)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Nimtrix once I can get C2 to stop crashing everytime I alt+tab in the latest build I will test it. Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)