Adding Touch Duration to Game?

0 favourites
  • 7 posts
From the Asset Store
Customize the animation of character when item changed
  • I'm creating an Autorunner game for phones and wanted to add Touch dratiom feature to it. By this i mean i wanted to add a function where the power/height of the players jump is determined by how long the user touchs the screen, so if the user does a quick tap to the screen to jump, it will do a light jump and if its a longer press to the screen, it will be a slightly more powerful jump.

    Currently i have set the character to jump the furthest that it can, so i'd like to implement a feature where the player can make shorter jumps by just tapping the screen.

    My capx file is much larger than 2mb so i'm unable to post this here.

    I don't know if this is possible but would any help with this using the Autorunner Template as an example.

    Thanks

  • You can try 'Every tick' + 'in touching object' -> incrase jump by 1;

    and 'on touch end' -> jump; jump = 0;

  • Thanks for the reply but thats not working for me, when i do a jump all it does is display the jumping animation which i have without actually jumping.

    I'm sure this can be done as many game have this but i just don't know how to do it.

  • [attachment=0:2ni4bdyk][/attachment:2ni4bdyk]

    Set the jump to the smallest jump you want. Then have a "on touch" that adds + 1 to the jump every tick.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the example but its not quite what i'm looking for. With your example, i am able to increase the jump by holding down on the touchscreen/mouse click but this doesn't really work for an autorunner where everything is constantly moving.

    I think Canabalt is the best example i could give of how i want to do it. With that, the jumping is based on duration of touch but the highest jump is capped no matter how long the button is pressed, thats is what i'm look for.

    Is this possible to do?

  • Ok, for that you do:

    While touching: make jump

    (subevent) On any end touch: Set Y vector to -50(or whatever negative number you want)

  • Thanks, i've tried that. It does work a little better, but does some weird animation at times. It may work better when if i tweak it.

    I found another way of doing it by changing the gravity, this way works better but the issue i have is that the jumping only works when i set it for Keyboard buttons. I can't seem to implement this with the touch feature as there is no change in the jump as there is with using a Keyboard.

    I've provided a capx file to show what i've done, hopefully you can help with this.

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