I have a runtime enterEvent listener setup, and inside it, under certain condition, I will generate some image objects, and then outside this event callback function and within the same lua file, I have another function that would try to remove the image objects that were created using display.remove api, and the image creation api I used is display.newImageRect.
I would really appreciate it if someone could point out the problem for me as I scratched my head and kind got stuck here for some time.
Here are some code snips from my gameBoard.lua file:
local tileMap = {}
local clear
local options
local sheet
local function onFrame( event )
…
tileMap[col][row] = display.newImageRect( sheet, number, 32, 32)
…
end
function clear()
…
display.remove(tileMap[col][row])
tileMap[col][row] = nil
…
end
local function init()
options =
{
width = 32,
height = 32,
numFrames = 64,
sheetContentWidth = 256, --width of original 1x size of entire sheet
sheetContentHeight = 256 --height of original 1x size of entire sheet
}
sheet = graphics.newImageSheet( “TestBlocks.bmp”, options )
Runtime:addEventListener( “enterFrame”, onFrame )
end