Touch/Tap looks glitchy does anybody know?

Hi

This problem is not recent, but it has been a concern for a while. The problem is the tap/touch event. What I find glitchy in them is when I want to remove an object that transition across the screen the tap/touch does not register, at times. It works fine, but when the object is moving fast the tap/touch does not register at times. Not only in the simulator but in the device, which is worse. I want to know if there is a code that enhances the tap/touch?

Thanks

Hi @seibittas,

It’s not that the touch/tap are glitchy, it’s just that by the time you’ve lifted up the touch (even if it’s 1/20th of a second), the fast-moving object may have exited the touch location, so it no longer senses that you “ended” on it. So essentially, it’s an implementation thing. You may want to consider increasing the overall size of the object by padding it with transparent pixels, so it appears the same size but it will be a slight bit more “forgiving” in regards to sensing touch “ended” upon it.

Best regards,

Brent

 I see what you mean. I had that same idea about increasing the size of the image. But the problem I find is the image would be overlapping other images. So they might click one thing, but instead it ends up clicking like 3 more things.

Dunno, tap is glitchy for me, too. :confused:

In coding, I usually maintain: “where there’s a will, there’s a way”.

How about doing something like this? It’s more complicated, but it may work as you need:

  1. When an object is touched (not tapped!) on the “began” phase, it gets assigned a custom property equal to the exact Runtime time when it was touched.

  2. At the same time, the touch’s .id gets logged into some table, and associated with the object’s ID (its Lua object ID).

  3. When the touch “ended” phase occurs on the stage (not the object, necessarily, since it may have passed beyond the touch point), you look up that touch ID in the table. Then you get the object ID associated with it. Then you compare the .time property of when that object was originally touched, and when the “ended” event took place. If the delta time is short enough, meaning that the object can’t be “too far past” the touch point, you take some action on the object (remove it, whatever). You could also do a distance comparison instead of a delta time comparison.

Anyway, give it some thought… it’s late on a Friday and the coding side of my brain is just about checked out for the week. :slight_smile:

Brent

@Brent I gave it some thought and I don’t know if I got it. This is what I did

local function ducky() local birds = display.newRect(0,0,50,50) birds.x = -100 birds.y = math.random(90,200) transition.to(birds, {time = 3000, x = 700}) local function dead(self, event) if event.phase == "began" then timer.performWithDelay(0, function() self:removeSelf() end ) end end birds:addEventListener("touch", birds) birds.touch = dead end timer.peformWithDelay(800, ducky, 0)

Was I close? or way off? of what you said.

Hi @seibittas,

It’s not that the touch/tap are glitchy, it’s just that by the time you’ve lifted up the touch (even if it’s 1/20th of a second), the fast-moving object may have exited the touch location, so it no longer senses that you “ended” on it. So essentially, it’s an implementation thing. You may want to consider increasing the overall size of the object by padding it with transparent pixels, so it appears the same size but it will be a slight bit more “forgiving” in regards to sensing touch “ended” upon it.

Best regards,

Brent

 I see what you mean. I had that same idea about increasing the size of the image. But the problem I find is the image would be overlapping other images. So they might click one thing, but instead it ends up clicking like 3 more things.

Dunno, tap is glitchy for me, too. :confused:

In coding, I usually maintain: “where there’s a will, there’s a way”.

How about doing something like this? It’s more complicated, but it may work as you need:

  1. When an object is touched (not tapped!) on the “began” phase, it gets assigned a custom property equal to the exact Runtime time when it was touched.

  2. At the same time, the touch’s .id gets logged into some table, and associated with the object’s ID (its Lua object ID).

  3. When the touch “ended” phase occurs on the stage (not the object, necessarily, since it may have passed beyond the touch point), you look up that touch ID in the table. Then you get the object ID associated with it. Then you compare the .time property of when that object was originally touched, and when the “ended” event took place. If the delta time is short enough, meaning that the object can’t be “too far past” the touch point, you take some action on the object (remove it, whatever). You could also do a distance comparison instead of a delta time comparison.

Anyway, give it some thought… it’s late on a Friday and the coding side of my brain is just about checked out for the week. :slight_smile:

Brent

@Brent I gave it some thought and I don’t know if I got it. This is what I did

local function ducky() local birds = display.newRect(0,0,50,50) birds.x = -100 birds.y = math.random(90,200) transition.to(birds, {time = 3000, x = 700}) local function dead(self, event) if event.phase == "began" then timer.performWithDelay(0, function() self:removeSelf() end ) end end birds:addEventListener("touch", birds) birds.touch = dead end timer.peformWithDelay(800, ducky, 0)

Was I close? or way off? of what you said.