Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Determine what square the mouse/style is over?

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
How do I know what square the mouse/stylist is over? (slanty)

I know there is TouchInput._x & TouchInput._y that give the pixel but how can I get the grid square x & y?

Forgive me as I'm sure this is a simple thing to do; I'm just being kind of lazy by asking for help. (glee)

Edit #1:

Well I'm dumb for not trying this before but I think I've got it solved now...
Math.floor(TouchInput._x / 48) & Math.floor(TouchInput._y / 48) seems to do the trick nicely. (cool)

Now I just need to find a way to check event ID by X & Y.
Would the best way be to check each event's X & Y against the above?
Seems like there is probably a better way. How can I do this?


Edit:
Just figured it all out... wasn't too hard...


Solutions:
To get the event
JavaScript:
$gameMap.eventsXy(Math.floor(TouchInput._x/48), Math.floor(TouchInput._y/48))
 
Last edited:
Top