kittykatattack / ga

The world's tiniest, cutest and funnest game engine
453 stars 85 forks source link

How to know which button was tapped #49

Closed fzzylogic closed 7 years ago

fzzylogic commented 7 years ago

This is a dumb question.. It's not a problem with ga, but with my understanding. I've made a group of ga buttons that call a function when tapped. They are generated in a for loop. I also gave each button additional attributes, including a unique id. But I can't figure out how to know in the callback which button was clicked.

I'm guessing I might have to do this by checking the cursor position at the time the callback is called and using that to work out what button is there. But just wondering if there's an easier / better way.. Is there some way to pass info to the callback for example? Would appreciate any suggestions on this..

Fwiw, some folks might be turned off off by the absence of a license, bcs the way many laws work is that no license = automatically protected. I don't like the global obsession with copyright myself, but that's the way it is at the moment.

Edit: Learned about the state property and am using that to loop through all buttons and see which one has a state of 'over'. Get's the job done but still curious if there's a more direct way.