I am trying to make my character jump when the screen is touched but it keeps giving me errors .
runner = display.newImage("runmann.gif") runner.x = 30 runner.y = 290 physics.addBody(runner, "dynamic", {density=.1, bounce=0.1, friction=.2, radius=12}) screenGroup:insert(runner)
function activateRunner( self, event ) self:applyForce(0, -3.5, self.x, self.y) end function touchScreen( event ) if event.phase == "began" then runner.enterFrame = activateRunner Runtime: addEventListener("enterFrame", Runner) end if event.phase == "ended" then Runtime: removeEventListener("enterFrame", Runner) end end function scene:enterScene(event) Runtime:addEventListener("touch", touchScreen) Runtime:addEventListener("collision", onCollision) end function scene:exitScene(event) Runtime:removeEventListener("touch", touchScreen) Runtime:removeEventListener("collision", onCollision) end
This is the error i’m getting
Runtime error
addEventListener: listener cannot be nil: nil
stack traceback:
[C]: in function ‘error’
?: in function ‘getOrCreateTable’
?: in function ‘addEventListener’
?: in function ‘addEventListener’
C:\Users\Brandon\Documents\Corona Projects\run man\game.lua:53: in funct
ion <C:\Users\Brandon\Documents\Corona Projects\run man\game.lua:49>
?: in function <?:221>
I posted the function where the error is .