Hello all,
I don’t understand why I keep getting this error message, individually local blackBar and local steelBar work fine, but when I try to run them at the same time I get the error message.
What am I doing wrong?
Appreciate any help,
Thanks
local blackBar local steelBar blackBar = display.newImageRect("blackBar.png", 60, 7) blackBar.x = 90 blackBar.y = 240 blackBar.rotation=0 physics.addBody( blackBar, "kinematic", { density=1.0, friction=0.3, bounce=1 } ) local function doRectTouch( event ) local touchedObject = event.target if event.phase == "began" then display.getCurrentStage():setFocus( touchedObject ) touchedObject.previousX = touchedObject.x touchedObject.previousY = touchedObject.y print("blackBar touched") elseif event.phase == "moved" then touchedObject.x = ( event.x - event.xStart ) + touchedObject.previousX touchedObject.y = ( event.y - event.yStart ) + touchedObject.previousY print("blackBar moved") elseif event.phase == "ended" or event.phase == "cancelled" then display.getCurrentStage():setFocus(nil) print("blackBar released") end return true end blackBar:addEventListener( "touch", doRectTouch ) local function blackBarTapped( event ) transition.to( blackBar, { rotation=20, delta= true } ) end blackBar:addEventListener( "tap", blackBarTapped ) return true steelBar = display.newImageRect("steelBar.png", 80, 10) steelBar.x = 90 steelBar.y = 240 --40 steelBar.rotation=0 physics.addBody( steelBar, "kinematic", { density=1.0, friction=0.1, bounce=1 } ) local function doRectTouch( event ) local touchedObject = event.target if event.phase == "began" then display.getCurrentStage():setFocus( touchedObject ) touchedObject.previousX = touchedObject.x touchedObject.previousY = touchedObject.y print("steelBar touched")