I’m having trouble figuring out the best way to associate touch events with specific objects in a group.
I have a touch function:
local function onTouch( event )
local t = event.target
that moves one of an array of objects around when dragged.
And elsewhere, I have a loop for altering the velocity of a set of objects:
for enemyID = 1, 8 do
enemy[enemyID].y = enemy[enemyID].y + enemyYV[enemyID]
enemyYV[enemyID] = enemyYV[enemyID] + .2
end
But I’m not sure how to alter the enemyYV[enemyID] value (velocity) in the touch function since I can’t tell how to identify which object in the enemy[enemyID] table is actually being touched.
I was thinking I’d need to loop through the table and match x.y coordinates of objects with x.y coordinates of the touch event, but that seems inelegant. Is there a better way?
[import]uid: 1560 topic_id: 325 reply_id: 300325[/import]