Hello!
i have a pause menu that works well the only error now is that then i resume my game it tells me:
Runtime error
?:0: attempt to index a nil value
stack traceback:
[C]: ?
?: in function ‘cancel’
…sx7vhhg96sjffvw0000gn/T/TemporaryItems/7/level01.lua:184: in function <…sx7vhhg96sjffvw0000gn>
?: in function <?:215>
i add the code associated with this problem under and hope that someone know the problem? i mean these functions shouldn’t even get executed because they are associated with the big button under the pause menu that aint related to the pause menu?
[lua]–A function the controls the ufos movement
function ufoMovement(event)
--An if that controls what happens then user hit anywhere on the screen and it goes up
if(event.target.name == “up” and crashed == false) then
--An if that fires an timer then touch began
if(event.phase == “began”) then
tmrUp = timer.performWithDelay(150, engines, 0)
--An elseif that checks then user stops to touch the button
elseif(event.phase == “ended”) then
timer.cancel(tmrUp)
spriteInstance.linearDamping = 0
--An elseif that checks if ufo has crashed then makes spriteInstance the crashedPos
elseif(crashed == true) then
spriteInstance.x = crashedPos
end
end
--An if that controls what happens then user hit the left button and it goes left
if(event.target.name == “left” and crashed == false) then
--An if that fires an timer then touch began
if(event.phase == “began”) then
tmrLeft = timer.performWithDelay(200, sideleft, 0)
--An elseif that checks then user stops to touch the button
elseif(event.phase == “ended”) then
timer.cancel(tmrLeft)
--An elseif that checks if ufo has crashed then makes spriteInstance the crashedPos
elseif(crashed == true) then
spriteInstance.x = crashedPos
end
end
--An if that controls what happens then user hit the right button and it goes right
if(event.target.name == “right” and crashed == false) then
--An if that fires an timer then touch began
if(event.phase == “began”) then
tmrRight = timer.performWithDelay(150, sideright, 0)
elseif(event.phase == “ended”) then
timer.cancel(tmrRight)
--An elseif that checks if ufo has crashed then makes spriteInstance the crashedPos
elseif(crashed == true) then
spriteInstance.x = crashedPos
end
end
end
–A function with a timer in that applys force to the sprite up
function engines(event)
spriteInstance.linearDamping = 0.5
spriteInstance:applyForce(0, -30, spriteInstance.x, spriteInstance.y)
end
–A function with a timer in that applys force to the sprite left
function sideleft(event)
spriteInstance:applyForce(-20, 0, spriteInstance.x, spriteInstance.y)
end
–A function with a timer in that applys force to the sprite right
function sideright(event)
spriteInstance:applyForce(20, 0, spriteInstance.x, spriteInstance.y)
end
–Three listeners that listen for touch on the different buttons in the game
buttonUp:addEventListener(“touch”, ufoMovement)
buttonLeft:addEventListener(“touch”, ufoMovement)
buttonRight:addEventListener(“touch”, ufoMovement)[/lua]
Kind Regards
Inkoqnito [import]uid: 90942 topic_id: 16847 reply_id: 316847[/import] </…sx7vhhg96sjffvw0000gn>
[import]uid: 84637 topic_id: 16847 reply_id: 63138[/import]