What's the preferred method for simulating a "tap"?

I'm building a simple game with my son where balloons float up the screen and you have to tap to pop them. Since we're getting it all working on the Mac I'm using the "mouse button down" and "mouse pointer inside" rules to simulate somebody actually tapping.

This works, except for one problem - you quickly figure out that you can just hold the mouse button down and wiggle the pointer across the screen to keep auto tapping. That's not what I want. I want each balloon to require a "press and release" sequence. I tried doing a "mouse pointer is inside and mouse button is up" version but that didn't work, then I didn't even have to push the button I just wiggle the pointer around.

Before I implement some sort of more complex "set state CLICKED=1 when mouse down and then look for CLICKED=1 and mouse is up" combination I thought I'd ask if there is a best practice for this sort of thing, especially since we ultimately would like to put this on his iPhone and I'm pretty sure that the mouse logic is going to have to switch over to touch logic anyway. I did try switching over to "touch position is inside and touch is released" but that doesn't seem to work at all when using mouse clicks.

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    When 'touch is released' should do the trick.

  • dmorin@gmail.comdmorin@gmail.com Member Posts: 19

    Well, that was easy! I was thinking that, as with the mouse bit, I needed some sort of "and position is inside" logic to go with it.

    Now I've got a different problem - some of my objects are so small and moving so fast that you can't actually tap them, because by the time you let your finger up the object has moved away from you. I'm guessing that, if that is the case, then my actor does not get a touch released event?

    I hadn't intended to make it this complicated, I'll adjust the size/speed of my objects so this is no longer a problem.

  • yattamoveyattamove Member Posts: 236

    Instead of "mouse", just use "touch is pressed".

  • stahboystahboy Member, PRO Posts: 150

    You could use the magnitude fcn to make a larger hitbox for smaller actors.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited September 2014

    Do you intend this to be for a device or Mac? With touch you won't have the ability on the device to hold your finger and destroy like with the mouse. If it's for Mac use when touch is released not when mouse is up. And remove the inside condition you don't need that.

Sign In or Register to comment.