Following a memory matching tutorial and I keep getting Failed to find image and the image is there

I’m following the last part of this memory matching tutorial and I cant for the life of me solve this issue.

The warning reads like such:

WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: Failed to find image ‘1.png’

20:45:18.602  WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: file ‘1.png’ does not contain a valid image

I cant find while I’m getting this message.

local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- -- local forward references should go here local widget = require "widget" widget.setTheme("widget\_theme\_android\_holo\_dark") user = loadsave.loadTable("user.json") -- this is where I put the local variables for my squares... local totalButtons = 0 --–Track total on screen buttons local secondSelect = 0 --– Track if first or second button select local checkForMatch = false --–Let the app know when to check for matches x = -20 --Set starting point for button grid -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- scene:create() function scene:create( event ) local sceneGroup = self.view -- Code here runs when the scene is first created but has not yet appeared on screen -- different background here local myRectangle = display.newImageRect(sceneGroup, "images/gamescreen/wood-walls.png", 620, 780 ) myRectangle.x = \_CX; myRectangle.y = \_CY; -- Create some buttons --Declare button, buttonCover, and buttonImages table local button = {} local buttonCover = {} local buttonImages = {1,1, 2,2, 3,3, 4,4, 5,5, 6,6} --Declare and prime a last button selected variable local lastButton = display.newImage("images/gamescreen/1.png"); lastButton.myName = 1; --Set up game function function game(object, event) if(event.phase == "began") then if(checkForMatch == false and secondSelect == 0) then --Flip over first button buttonCover[object.number].isVisible = false; lastButton = object checkForMatch = true elseif(checkForMatch == true) then if(secondSelect == 0) then --Flip over second button buttonCover[object.number].isVisible = false; secondSelect = 1; --If buttons do not match, flip buttons back over if(lastButton.myName ~= object.myName) then matchText.text = "Match Not Found!"; timer.performWithDelay(1250, function() matchText.text = " "; checkForMatch = false; secondSelect = 0; buttonCover[lastButton.number].isVisible = true; buttonCover[object.number].isVisible = true; end, 1) --If buttons DO match, remove buttons elseif(lastButton.myName == object.myName) then matchText.text = "Match Found!"; timer.performWithDelay(1250, function() matchText.text = " "; checkForMatch = false; secondSelect = 0; lastButton:removeSelf(); object:removeSelf(); buttonCover[lastButton.number]:removeSelf(); buttonCover[object.number]:removeSelf(); end, 1) end end end end end --Place buttons on screen for count = 1,3 do x = x + 90 y = 20 for insideCount = 1,4 do y = y + 90 --Assign each image a random location on grid temp = math.random(1,#buttonImages) button[count] = display.newImage(buttonImages[temp] .. ".png"); --Position the button button[count].x = x; button[count].y = y; --Give each a button a name button[count].myName = buttonImages[temp] button[count].number = totalButtons --Remove button from buttonImages table table.remove(buttonImages, temp) --Set a cover to hide the button image buttonCover[totalButtons] = display.newImage("btn.png"); buttonCover[totalButtons].x = x; buttonCover[totalButtons].y = y; totalButtons = totalButtons + 1 --Attach listener event to each button button[count].touch = game button[count]:addEventListener( "touch", button[count] ) end end end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

Can somebody help me hear???

Screen shot attached

Are you sure there’s an image named “1.png” located at your main directory(the place you store your lua files)?

Does the image images/gamescreen/1.png exist?

I think he meant to do this at line 95

button[count] = display.newImage("images/gamescreen/" .. buttonImages[temp] .. ".png");

WoW thanks for the reply fellas. I went to Mcdonalds real quick, came back and BAM!!!

I’m gonna go through each solution one by one.

1.png is in my gamescreen folder with 8 other .png images 1-8.

I’m thinking maybe that 1.png file needs to be the square and not the images.

I have the square labled btn.png

I’m going to go through it all right now.

also I left a screen shoot of my directory tree.

for future reference this subforum is dead I suggest you post lua errors in 

https://forums.coronalabs.com/forum/532-newbie-questions/

Or if it’s more complex

https://forums.coronalabs.com/forum/600-general-questionsdiscussion/

well I dont have it in my main.lua file I have it in my scene_game.lua file and I’m looking right at 1.png in my gamescreen folder. my back ground for this scene pops up but thats in another function (which is stored in the same file)

 --Assign each image a random location on grid temp = math.random(1,#buttonImages) button[count] = display.newImage("images/gamescreen/" .. buttonImages[temp] .. ".png"); --Position the button button[count].x = x; button[count].y = y; 

I did this and now the error is this:

WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: Failed to find image ‘3.png’

22:43:08.810  WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: file ‘3.png’ does not contain a valid image

why 3.png now?

yeah I’m looking right at it…

Are you sure there’s an image named “1.png” located at your main directory(the place you store your lua files)?

Does the image images/gamescreen/1.png exist?

I think he meant to do this at line 95

button[count] = display.newImage("images/gamescreen/" .. buttonImages[temp] .. ".png");

WoW thanks for the reply fellas. I went to Mcdonalds real quick, came back and BAM!!!

I’m gonna go through each solution one by one.

1.png is in my gamescreen folder with 8 other .png images 1-8.

I’m thinking maybe that 1.png file needs to be the square and not the images.

I have the square labled btn.png

I’m going to go through it all right now.

also I left a screen shoot of my directory tree.

for future reference this subforum is dead I suggest you post lua errors in 

https://forums.coronalabs.com/forum/532-newbie-questions/

Or if it’s more complex

https://forums.coronalabs.com/forum/600-general-questionsdiscussion/

well I dont have it in my main.lua file I have it in my scene_game.lua file and I’m looking right at 1.png in my gamescreen folder. my back ground for this scene pops up but thats in another function (which is stored in the same file)

 --Assign each image a random location on grid temp = math.random(1,#buttonImages) button[count] = display.newImage("images/gamescreen/" .. buttonImages[temp] .. ".png"); --Position the button button[count].x = x; button[count].y = y; 

I did this and now the error is this:

WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: Failed to find image ‘3.png’

22:43:08.810  WARNING: C:\Users\jason\Documents\matching game HW1\scene_game.lua:95: file ‘3.png’ does not contain a valid image

why 3.png now?

yeah I’m looking right at it…