Can someone please explain this part of the DragMe example?

I’m working with selecting the top object when a touch applies to several overlapping objects. I know that the code in DragMe works, but being a nosey bugger I’d like to know why. :wink:

Thanks!

Tom [import]uid: 55068 topic_id: 12693 reply_id: 312693[/import]

Ah, I’ve got it.

For anyone else googling how to select the top-most object with a touch, here’s the code…

[lua]local isFocus = nil;

function selectObject(event)
if(event.phase==“began” and event.target ~= nil) then

if (isFocus==nil) then
isFocus = true; – used to select top one
selectedThing = event.target;
end

display.getCurrentStage():setFocus(event.target);
end

if(event.phase == “ended”) then
isFocus = nil;
end
end[/lua] [import]uid: 55068 topic_id: 12693 reply_id: 46495[/import]