I am trying to load a list of filenames into a table, and the use that table to create new images. The issue I am having is after the image table is loaded, the display.newImage() function will not work with a variable loaded from a file as an argument
Load Table Code
[lua]-- Load the Background Image Table
local path = system.pathForFile( “backgroundlevels.txt”, system.ResourceDirectory )
local counter = 1
for line in io.lines(path) do
globals.backgrounds[counter] = line
counter = counter + 1
end[/lua]
Select the Image to display
[lua]globals.currentScene = 1[/lua]
The contents of globals.backgrounds[globals.currentScene] is 1-1.png
Create Image code
[lua]function currentScene.loadCurrentScene()
local filePath = globals.backgrounds[globals.currentScene]
currentScene.background = display.newImage(filePath, 0 ,0)
end [/lua]
the error I am getting is below
b/c it does not exist.ath for resource file '1-1.png
)ARNING: Failed to find image(1-1.png
Runtime error
assertion failed!
[import]uid: 7664 topic_id: 1738 reply_id: 301738[/import]
[import]uid: 5712 topic_id: 1738 reply_id: 8074[/import]