Okay, so I am trying to keep my code short in my game so I can quickly and (practically) effortlessly change something if I needed to. Therefore I have been using tables to create similar objects, place them, create their event listeners, remove them, etc. However I was wondering how you could possibly pass a number between an event listener and a function.
The code explains it:
local function gotolevel(event, number1)
if(event.phase == “ended”) then
print(“hi”)
if(event.target.alpha > 0.9) then – If its alpha is not 1, then you can’t go there
print("level "…number1)
storyboard.gotoScene(“level”…tostring(number1), options)
else
print(“can’t go there”)
end
end
end
for i = 1, 3 do
box[i]:addEventListener(“touch”, gotolevel, i) --I want it to pass what number box it is
end
Basically I want the boxes to pass their number and then whenever they are called, the function would go to the correct scene. Please point out any errors you see.