[edit: added code tag for clarity in reading, and images array added]
I am trying to pass the value of an array (to see if it is the correct answer) into a function that will evaluate if it isCorrect()
[code]–build array for the level
local quadlevels = {
{ name=“level01”, hint=“Hint For Level 01”, correctAns=“01_Sky_A.jpg”, quad1=“01_Sky_A.jpg”, quad2=“01_Sky_B.jpg”, quad3=“01_Sky_C.jpg”, quad4=“01_Sky_D.jpg”, },
{ name=“level02”, hint=“Hint for Level 02”, correctAns=“02_Water_B.jpg”, quad1=“02_Water_A.jpg”, quad2=“02_Water_B.jpg”, quad3=“02_Water_C.jpg”, quad4=“02_Water_D.jpg”, }
}
local images = {quadlevels[gameLevelValue].quad1, quadlevels[gameLevelValue].quad2, quadlevels[gameLevelValue].quad3, quadlevels[gameLevelValue].quad4}
index = 1
for i = 1, 2 do
for j = 1 , 2 do
local imageLoop = {}
imageLoop[index] = display.newImageRect(group, images[index], 300, 300)
transition.from(imageLoop[index], {time=2000, alpha=0})
group:insert(imageLoop[index])
imageLoop[index]:setReferencePoint(display.TopLeftReferencePoint)
imageLoop[index]:addEventListener(‘touch’,isCorrect) --imageLoop[index]:addEventListener(‘touch’,isCorrect(“clickedItemName”))
index = index + 1
end
end
function isCorrect(clickedItemName)
if clickedItemName = correctAns.Value, “Good Job”
else
if clickedItemName <>correctAns.Value, “Incorrect”
end
[/code]
Easy right? I just don’t know the syntax.
Does anyone know how to pass a value into a function?
–Shawn
[import]uid: 132937 topic_id: 35096 reply_id: 335096[/import]