Posted: 28th Dec 2021 21:09
In Warlordocracy, the player can click on objects to interact with them. Right now I just get the sprite size and see if the cursor is there, but I would love a way to test if the cursor is currently over a transparent pixel in the sprite to make it more accurate. Is there any way to do this in AppGameKit?

Steam Demo Link
Posted: 29th Dec 2021 13:45
you're asking for pixel-perfect accuracy which, in my opinion, is overkill and would be a serious performance hit.

that being said, and keeping your current method as a base, once the sprite is detected, you would have to figure out which image (frame, if animated?) it's using, calculate which pixel in that image the pointer is currently over, turn that pixel into a memblock and read its alpha value there to achieve what you're looking for.

instead, consider using SetSpriteShapePolygon() for improved accuracy.
Posted: 29th Dec 2021 14:21
a little more toward "pixel perfect": you could do some prep work for the sprites and keep the memblocks on-hand for quick "look up" vs determining image and creating the memblocks "live". short on time, now, but THIS might help explain the theory.

finally, and speaking of overkill, many wouldn't consider using Box2D for something like this because you're really not needing "physics" per se but with the additional sprite shapes that the system allows and the multi-thread usage that Box2D affords, you should see a performance boost with while increasing "sprite shape" accuracy overall.
Posted: 31st Dec 2021 6:44
Thanks man, I just discovered a more urgent problem that's gonna give me an aneurism. I'll get back soon.
Posted: 31st Dec 2021 11:22
You're better off using hitboxes if you're just detecting collisions.