Hello! I am trying to integrate a basic shape-matching in storyboard. I’ve used this as a reference http://www.coronalabs.com/blog/2013/01/29/basic-shape-matching-app/.
This is my scene1.lua file
--------------------------------------------------------------------------------- -- -- scene1.lua -- --------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local MultiTouch = require("dmc\_multitouch") --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local background local dispObj\_5 local countries193 MultiTouch.activate(countries193, "move", "single"); local countries193PosX = 0; local countries193PosY = 0; local function countries193Drag (event) local t = event.target if event.phase == "moved" then countries193PosX = countries193.x - dispObj\_5.x; countries193PosY = countries193.y - dispObj\_5.y; if (countries193PosX \< 0) then countries193PosX = countries193PosX \* -1; end if (countries193PosY \< 0) then countries193PosY = countries193PosY \* -1; end if (countries193PosX \<= 50) and (countries193PosY \<= 50) then countries193.x = dispObj\_5.x; countries193.y = dispObj\_5.y; end elseif event.phase == "ended" then if (countries193PosX \<= 50) and (countries193PosY \<= 50) then countries193.x = dispObj\_5.x; countries193.y = dispObj\_5.y; -- If you'd like to be able to move the square again, comment out the line below MultiTouch.deactivate(countries193); end end return true; end -- Called when the scene's view does not exist: function scene:createScene( event ) local screenGroup = self.view background = display.newImage( "background.png" ) screenGroup:insert( background ) countries193 = display.newImageRect( "level23\_193.png", 55, 40 ) countries193.x = 75 countries193.y = 275 screenGroup:insert( countries193 ) countries193:addEventListener(MultiTouch.MULTITOUCH\_EVENT, countries193Drag); dispObj\_5 = display.newImageRect( "level23\_input.png", 60, 36 ) dispObj\_5.x = 242 dispObj\_5.y = 201 screenGroup:insert( dispObj\_5 ) end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) storyboard.printMemUsage() -- remove previous scene's view storyboard.removeAll() -- Update Lua memory text display end -- Called when scene is about to move offscreen: function scene:exitScene( event ) end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene
The error i’m getting:
Runtime error: dmc\_touchmanage.lua:133: table index is nil
I’ve added the archieve touch.lua if someone wants to view the full code source.
I appreciate any help!
Thank you.