Englisch Detecting the player cursor on an inaccurate image

2 Antworten
Gehe zu Seite
Zum Anfang Vorherige 1 Nächste Zum Anfang
Hoch
The Dark Shadow
User
Offline Off
How to detect if the player cursor is exactly on an inaccurate/not fit image in pixel, Skipping transparent pixels? For example a circle, a rectangle, a star, or whatever. Not possible? Would it be hard? Would it be laggy while each positions/pixels of the image would be calculated? What's the most decent way to get that?

Would be appreciated as well.
30.07.20 00:42:39
Hoch
DC
Admin
Offline Off
CS2D doesn't offer any utility methods for something like that. It's probably possible but not easy.

You would somehow have to read and store the information which pixels are transparent. I can only think of two ways to do so:
• write a PNG reader in Lua or use an existing one e.g.: https://github.com/Didericis/png-lua and use it to read, extract and store the alpha information
• or do the PNG reading and processing beforehand with other software and somehow store the information in a format which can be read in Lua easily (or directly export the information as Lua table)

Afterwards you can use cs2d lua cmd player mousemapx and mousemapy and the position of the Lua image to calculate the cursor position in the image and then - if the cursor hovers the image - check against your data if there is transparent pixel at that position or not.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
30.07.20 09:25:26
Hoch
The Dark Shadow
User
Offline Off
@user DC: Alright, I'm gonna do that, Thanks sir
Zum Anfang Vorherige 1 Nächste Zum Anfang