I was trying to optimize/minimize the following code and wanted to concatenate the stage:setFocus code as follows:
stage:setFocus("ball" .. event.target.ballId)
Unfortunately this does not appear to be working as the ball clicked is not getting focus. Is such concatenation possible and if so anyone identify any problems with my attempt?
local function onPressBall ( event )
print ("press ball" .. event.target.ballId)
local phase = event.phase
local stage = display.getCurrentStage()
if "began" == phase then
if event.target.ballId == 1 then
stage:setFocus(ball1)
elseif event.target.ballId == 2 then
stage:setFocus(ball2)
end
elseif "ended" == phase then
stage:setFocus(nil)
end
end
Thanks
Paul [import]uid: 7863 topic_id: 2221 reply_id: 302221[/import]