I wrote two projects, one of which uses native extensions. The first generates a special file with data of image transparency. The second uses it to determine if the sprite is clicked or not.
Now you can determine whether the game object clicks, even if it is of complex shape without physics!
How to use
- Open ImageTransparencyCalculator project
- Put images in a folder
Images
and write their size inimage_data.lua
- Run the project and click anywhere. It will close automatically, and files will appear in the folder
generated_data
- Copy generated files to folder
generated data
in projectCheck Click
- Position the game object with the sprite in the game. Plug in module
check_click.lua
- Specify game object identifiers to load their data
- You can check clicked game object or not using check_click.check(game_object_id, x, y)
- Specify a folder
generated_data
in custom resources
Perfect accuracy is often not needed, you can customize it and reduce the file size here:
(ImageTransparencyCalculator project)
Link: https://github.com/JAlHund/ImageTransparencyCalculator
License: MIT
Written for Defold 1.2.169
The texture of London from my game. We all perfectly understand that not all of London is like that, and this is just the name of the province