Let say i have 5 enemy sprite in local Enemy = {}.I Enemy[i].sprite:addEventListener() to all the 5 sprites. I have the event.target generated by the event listener. how am i going to find which index does the event.target belongs to? [import]uid: 40786 topic_id: 24108 reply_id: 324108[/import]
The lua ‘table’ has an ‘indexOf’ function which tells you the array index of an object within that table:
http://developer.anscamobile.com/reference/index/tableindexof
However, if you want to find the index of a display object within a display group you could use the ‘indexOf’ function from my display extensions library:
https://developer.anscamobile.com/code/display-extensions [import]uid: 8271 topic_id: 24108 reply_id: 97271[/import]