the code works as it won’t get stuck now. the problem is if i double click the item i get a error.
Runtime error
…emanouel/CoronaProjects/HH/scene1.lua:27: attempt to index upvalue ‘text1’ (a nil value)
stack traceback:
[C]: ?
…emanouel/CoronaProjects/HH/scene1.lua:27: in function <…emanouel>
(tail call): ?
?: in function <?:1184>
?: in function <?:226>
<br>---------------------------------------------------------------------------------<br>-- Room 1<br>---------------------------------------------------------------------------------<br>local storyboard = require( "storyboard" )<br>local scene = storyboard.newScene()<br>---------------------------------------------------------------------------------<br>-- BEGINNING OF YOUR IMPLEMENTATION<br>---------------------------------------------------------------------------------<br>local background, room2, blackKey, blackdoorlocked, text1 <br><br>-- Touch event listener for background image<br>local function gotoRoom2( self, event )<br> if event.phase == "began" then<br> <br> storyboard.gotoScene( "scene2", "fade", 400 )<br> <br> return true<br> end<br>end<br><br>local function door1locked( self, event )<br> if event.phase == "began" then <br> print ("clicked on Door Locked")<br> text1 = display.newText( "Door is Locked, the key should be near by", 0, 245, native.systemFontBold, 20 )<br> text1:setTextColor( 255 ) <br> --transition.to(text1, {time=1000, onComplete = function() display.remove(text1) end})<br> transition.to(text1, {time=1000, alpha=0.0, onComplete=function() text1:removeSelf(); text1 = nil; end})<br> return true <br> end<br>end<br><br>local function foundBlackKey( self, event )<br> if event.phase == "began" then<br> print ("Door 1 Is Now Open")<br> blackdoorlocked.isVisible = false<br> blackKey.isVisible = false<br> storyboard.settings.keyFound[1] = true<br> storyboard.settings.doorUnLocked[1] = true<br> storyboard.saveTable(storyboard.settings, "settings.json")<br> return true<br> end<br>end<br><br>-- Called when the scene's view does not exist:<br>function scene:createScene( event )<br> local screenGroup = self.view<br> <br> background = display.newImage( "assets/graphics/Room1.png", 0, 0 )<br> screenGroup:insert( background )<br> <br> room2 = display.newImage( "assets/graphics/gotoRoom2.png", 175, 0 )<br> screenGroup:insert( room2 )<br> <br> room2.touch = gotoRoom2<br> <br> blackKey = display.newImage( "assets/graphics/BlackKey.png", 400, 250 )<br> screenGroup:insert( blackKey )<br> blackKey.touch = foundBlackKey<br> blackKey.isVisible = true<br> <br> blackdoorlocked = display.newImage( "assets/graphics/BlackDoorLocked.png", 175, 0 )<br> screenGroup:insert( blackdoorlocked )<br> blackdoorlocked.touch = door1locked<br> blackdoorlocked.isVisible = true<br> <br>if storyboard.settings.doorUnLocked[1] == true then<br> -- the level is locked<br> print ("DOOR 1 IS UNLOCKED")<br> blackdoorlocked.isVisible = false<br>else<br> -- the level is unlocked<br> print ("DOOR 1 IS LOCKED")<br> blackdoorlocked.isVisible = true<br>end <br><br>if storyboard.settings.keyFound[1] == true then<br> print ("THE KEY WAS FOUND")<br> blackKey.isVisible = false<br>else<br> print ("THE KEY WAS NOT FOUND")<br> blackKey.isVisible = true<br>end <br><br> print( "\n1: createScene event")<br>end<br><br>-- Called immediately after scene has moved onscreen:<br>function scene:enterScene( event )<br> local group = self.view <br> print( "1: enterScene event" )<br> <br> local lastScene = storyboard.getPrevious()<br> <br> print( "last scene was:", lastScene ) -- output: last scene name<br> <br> -- Update Lua memory text display<br> room2:addEventListener( "touch", room2 )<br> blackKey:addEventListener( "touch", blackKey )<br> blackdoorlocked:addEventListener( "touch", blackdoorlocked )<br><br>end<br><br>-- Called when scene is about to move offscreen:<br>function scene:exitScene( event )<br> local group = self.view <br> print( "1: exitScene event" )<br> <br> -- remove touch listener for image<br> room2:removeEventListener( "touch", room2 )<br> blackKey:removeEventListener( "touch", blackKey )<br> blackdoorlocked:removeEventListener( "touch", blackdoorlocked )<br>end<br>-- Called prior to the removal of scene's "view" (display group)<br>function scene:destroyScene( event )<br> local group = self.view<br> print( "((destroying scene 1's view))" )<br>end<br><br>---------------------------------------------------------------------------------<br>-- END OF YOUR IMPLEMENTATION<br>---------------------------------------------------------------------------------<br><br>-- "createScene" event is dispatched if scene's view does not exist<br>scene:addEventListener( "createScene", scene )<br><br>-- "enterScene" event is dispatched whenever scene transition has finished<br>scene:addEventListener( "enterScene", scene )<br><br>-- "exitScene" event is dispatched before next scene's transition begins<br>scene:addEventListener( "exitScene", scene )<br><br>-- "destroyScene" event is dispatched before view is unloaded, which can be<br>-- automatically unloaded in low memory situations, or explicitly via a call to<br>-- storyboard.purgeScene() or storyboard.removeScene().<br>scene:addEventListener( "destroyScene", scene )<br><br>---------------------------------------------------------------------------------<br><br>return scene<br>
so im assuming i need to put event listeners for the text >?? i have event listeners for the object as seem in the code above. [import]uid: 17701 topic_id: 25923 reply_id: 108953[/import] </…emanouel>