If I want to use the same listener subroutine for multiple images, is there a way to tell which image was touched?
Hi John,
Yes, this is represented by “event.target”. See this guide:
http://docs.coronalabs.com/guide/events/touchMultitouch/index.html
Brent
Thanks for the reply. That’s just what I need!
Is it better or faster to have one handler or a handler for each item? There will be about 40+ items soso 40+ listeners on the page.
John
Hi John,
Almost always better to use one handler for multiple items (don’t repeat yourself in code unless necessary). The exception, I suppose, would be if you had a handler function with dozens of conditional statements based on one type of item, while the rest of the items didn’t need to worry about most of that… but even then, I’d probably opt for one handler and just if-then it all out based on the item type or similar.
Brent
Hi John,
Yes, this is represented by “event.target”. See this guide:
http://docs.coronalabs.com/guide/events/touchMultitouch/index.html
Brent
Thanks for the reply. That’s just what I need!
Is it better or faster to have one handler or a handler for each item? There will be about 40+ items soso 40+ listeners on the page.
John
Hi John,
Almost always better to use one handler for multiple items (don’t repeat yourself in code unless necessary). The exception, I suppose, would be if you had a handler function with dozens of conditional statements based on one type of item, while the rest of the items didn’t need to worry about most of that… but even then, I’d probably opt for one handler and just if-then it all out based on the item type or similar.
Brent