How do I change direction with tap?

0 favourites
  • 6 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello. My first post! I am going through tutorials and learning the basics of C2 at this point.

    I want to create a simple player control where each tap reverses the player movement.

    Game Start: Player Idle

    First Tap: Player moves right

    Second Tap: Player moves left

    Third Tap: Player moves right

    and so on, while continuously facing forward. Can anyone point to the tutorial or methods to do this?

    I am trying to detect which way the Player is moving and accelerating towards Player.X + or - 2000, but not doing anything correctly, not to mention this probably requires 2 taps to reverse movement.

    (Pic of my failed control attempt)

    https://drive.google.com/open?id=0ByWkQ ... 2Y1UHRBdkE

    Thank you in advance.

  • First off, welcome to the wonderful world of C2!

    You could put a boolean instance variable on the player to keep up with which way it's going. call it "isleft" (or whatever you like).

    on touch >>>

    (subevent)-If player isleft = "true" >>> set isleft false AND start moving player right

    ----------------Else >>> set isleft true and start moving player left.

    EDIT: oh, actually that won't work with the way you're doing the movement...

    let me rewrite:

    on touch >>>

    (subevent)-If player isleft = "true" >>> set isleft false

    ----------------Else >>> set isleft true

    (new event)

    if player isleft=true >>> move left

    else >>> move right.

  • Thanks for the welcome and the reply spacedoubt!

    Will give this method a try!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks to your advice I was able to move left and right with a tap!

    It is working splendidly.

    However, if I make a quick successive taps, it will only register the turn once.

    (if I double tap, the two actions should cancel out so the player should zigzag a bit and keep going. However currently it will only recognize one tap, and will only change direction once)

    How would I be able to fix this issue?

    Here is the Capx file just incase.

    https://drive.google.com/open?id=0ByWkQ ... WprRmdIZkU

    Here is the Event page screenshot

    https://drive.google.com/open?id=0ByWkQ ... m1FT3Y5VTA

  • Fixed myself!

    I changed input event from "on tap" to "any touch start" and its working now!

  • Sweet! Yeah, 'on tap' triggers on a quick touch and release... It also makes me want a beer...

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