ImageSprite.Touched event even if touch outside of ImageSprite?

this is all the block:

I touched out side the imageSprite, but the ImageSprite.Touched event still fires.
Why?
imageSpriteTouched.aia (2.6 KB)

Not seeing that behaviour here with you aia ? (with companion app)

You can see the black dot is not within imageSprite.

I am also in companion.

Edit:
same also in apk in real phone.

What is the setting of the Sizing property? Sometimes when the screen initializes with Fixed sizing the scaling is off the first time and so where the content is drawn vs where the contents bounds are do not line up. This shouldn't happen in Responsive mode.

I played with touch down and touch up, getting a touchdown circle in the square, and a touch up outside of the square (having moved the square to see the circles). So possibly two events occurring?

Project property-General-Sizing is set to responsive.

both happen outside of the imageSprite here.

Device name, Android version?

My phone:
Vivo iQOO Neo 8
Android 13

Emulator:
LDPlayer
Android 9

Unfortunately, I don't have any test devices from this manufacturer.

Its a Chinese brand.
So you do not have any same issue on your phones?

I have some devices from Chinese manufacturers (Xiaomi, Huawei, OnePlus, ...), but I haven't tested them yet because these devices need to be woken up from their deep sleep and charged.

1 Like

No issues on Huawei P20 lite, Android 9.

1 Like

I found this issue when I am blocking an sliding app,
When I click the middle clearance of two ImageSprite, two sprites may slide together, which I need to avoid.

Xiaomi Mi 9, Android 10, no issue.

1 Like

That sounds like sprite cannibalism.

You can avoid it using a single global variable, to hold the chosen Sprite component you want to move. Set it at touch Down time, and use it in the TouchUp or Drag event generically.

1 Like

I knew cannibanism when imagesprites overlapping. But my issue is all imagesprite do not overlap each other, there are enough spaces (i think) between them. I touched the space, which is obviously outside the sprite, but still fired the touched event of this sprite.

Hmm. So I think the issue here has to do with how we handle touch events in the canvas. There is a constant to represent the width of a finger in pixels and then if a square of that width/height centered on the touch point intersects the sprite it is considered touched. The constant is currently 24 px. I thought there had been a PR at some point to make this configurable, in which case you could set the threshold to something very smaller for better accuracy, but I haven't had a chance to locate it.

Never mind, it was the tap threshold that was made adjustable. We'd probably want a similar change to allow for adjusting the finger size.

I see the effect of a maybe 10 px border around the sprite where the sprite fires.
The image was right sized to 50 by 50 px.
Changing the sprite size from automatic to 50 by 50 did not help, not did changing the Screen from responsive to fixed.

I vaguely remember an Android fat finger fudge factor for touch radius, but don't remember its name.

To work around this, consider just getting the Canvas Touch coordinates, and choose the closest block center, using Manhattan distance.