Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetSrpiteHit on a rendered image

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 12th Aug 2016 20:01
Hi,
Is it possible to write a function like GetSpriteHit which will work on sprites which are rendered on an image?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Aug 2016 08:00
You could put invisible sprites over the top of the areas you want to "hit".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Aug 2016 09:13
Since I want the rendered image movable on the screen, I cannot imagine how this will work.
If I'll keep track where the sprites of the rendered image are, then the image will be useless to me...
My task is to create a movable surface which will contains various user interface controls.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Aug 2016 10:32
You can construct your own collision shape for a sprite, but that wouldn't really help if you need to detect different areas.

The straightforward option is what batvink suggests, having invisible sprites positioned where you need them, and move them with the rendered sprite.

Another option really only applies if you can use rectangular areas for hit detection. What I would consider doing, is sketching out the rendered sprite on paper, graph paper if you have it - then work out the position of the mouse in relation to the rendered sprite, so it's 0.0 - 1.0, to make up for sprite scaling. Then you display the difference on the screen, and take note of the coordinates. Then I'd fill and array with these coordinates and would use that to detect where the mouse is.
The code is dark and full of errors
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Aug 2016 13:59
Thanks both for the tips

Login to post a reply

Server time is: 2024-11-25 04:38:20
Your offset time is: 2024-11-25 04:38:20