It looks like you're new here. If you want to get involved, click one of these buttons!
So my game just uses touch to trigger a jump.
I'm thinking of doing a hold screen to make the character duck under objects
So I think I need to start with a touch began statement calculate past two frames so that he ducks during that hold. Then when there's a touch end he doesn't jump.
Does that sound right?
Thanks
Comments
yes.
measure the time t of hold, and if t > t_hold, then duck and do not jump.
Awesome thank you @Jmv38 !
My code isn't working because I'm using a timer = timer+1 and it's resetting. I think I need to use a delta timer instead to calculate the hold...
@Majormorgan Here's an example. I didn't add jump or duck code so I just move the sprite up or down to show jump or duck. You can add you're own jump/duck code. Tap screen to jump. Tap and hold for greater than .2 seconds to duck.
@Majormorgan This isn't the hold screen or tap screen, but a flick in an up or down direction to jump or duck. With a flick up or down, there isn't the delay to determine if the touch is being held to cause the duck. Also, there isn't a need for a timer.
Hey @dave1707 they are both cool examples and the swipe up and swipe down could be an even better answer! I'm coding In your timed approach above for the hold approach. I've got the less than tmr delay working. Still not cracked the hold part yet, but I'm almost there. I have to modify you code because of the engine I built is different.
Your ideas are really cool. I'll post when I have it working
Thank you so much!
Cool!
In the end the principle of the code worked really well and I had to create some rules around the specific things in my game. But the code idea was really helpful!