I am working on an app where students are given 4 directional arrows to select. They can select as many arrows as often as they like up to a sequence of 20. When they press “Go” the character moves according to the arrows chosen. My problem is this…
Each time a student selects an arrow, I show an image of it in a specific location. There is a clear button that erases the images so they can do it again. To this point, things work fine, but when an arrow is chosen after the images have been cleared I get an error “attempt to call global ‘image1’ (a table value)” I think it is how I am clearing the images, but I’m not sure. Snippets of code are pasted below.
--check the counter and call the image
function checkForwardFunction()
if turn1 == null then
clear = true
turn1 = "forward" counter=counter+1,image1() else if turn2 == null then
turn2 = "forward" counter=counter+1,image2()
end
end
Here is the table and how I am calling the image to the screen
imageTable = {}
imageTable[1] = "images/goForward.png"
imageTable[2] = "images/turnRight.png"
imageTable[3] = "images/goBackward.png"
imageTable[4] = "images/turnLeft.png"
imageTable[5] = "images/invisibleSquare.png"
function image1()
imageGroup = display.newGroup()
if
turn1 == "forward" then
image1 = display.newImage(imageTable[1])
image1.x= 50; image1.y = 30
imageGroup:insert(image1)
print(imageGroup)
print("first image added")
else if turn1 == "right" then
image1 = display.newImage(imageTable[2])
image1.x= 50; image1.y = 30
imageGroup:insert(image1)
else if turn1 == "backward" then
image1 = display.newImage(imageTable[3])
image1.x= 50; image1.y = 30
imageGroup:insert(image1)
else if turn1 == "left" then
image1 = display.newImage(imageTable[4])
image1.x= 50; image1.y = 30
imageGroup:insert(image1) else if
turn1 == nil then
image1 = display.newImage(imageTable[5])
end
end
end
end
end
end
Here is how I am clearing the images from the screen
function removeImages()
print (imageGroup)
imageGroup:removeSelf()
imageGroup = nil
end
any help would be appreciated.
Thanks [import]uid: 48122 topic_id: 19810 reply_id: 319810[/import]