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