[Resolved] Accelerometer not responding at restart

I’m really confused here. When the game ends on the simulator and I click “retry”, no errors pop up. But when I play on my device and click retry, my player is unresponsive to the accelerometer.

in the gameover.lua

[code]
local retrybutton = display.newImage (“retryBtn.png”)
retrybutton.x = 340
retrybutton.y = 135
localGroup:insert(retrybutton

local function pressretry (event)
if event.phase == “began” then
director:changeScene (“game”)
background = nil
end

player movement in the game.lua
function movePlayer(event)
player.y = display.contentCenterY - (display.contentCenterY * (event.yGravity*3))

if player.y - player.height * 0.7 < 0 then
player.y = player.height * 0.7
elseif player.y + player.height * 0.7 > display.contentHeight
then
player.y = display.contentHeight - player.height * 0.7
end
end
Runtime:addEventListener(“accelerometer”, movePlayer)

And I am ending the frames in the game over function. I don’t know what I’m doing wrong here.
end
retrybutton:addEventListener(“touch”, pressretry)
[import]uid: 114389 topic_id: 27049 reply_id: 327049[/import]

Lines 25-27 aren’t part of the code. [import]uid: 114389 topic_id: 27049 reply_id: 109821[/import]

Have you tried hooking up your device to your Mac and checking the console while it is running?

I have an app using Director and the accelerometer and it doesn’t encounter this problem. (Mentioning that just as an FYI so while attempting to isolate further you know it’s not down to Director.) [import]uid: 52491 topic_id: 27049 reply_id: 109873[/import]

Nevermind I figured it out. I would delete this post if I could. [import]uid: 114389 topic_id: 27049 reply_id: 110161[/import]

Maybe you could post your solution for others in the future? I’m sure it would be most appreciated - if it was a user error then other users are sure to encounter it too :slight_smile: [import]uid: 52491 topic_id: 27049 reply_id: 110234[/import]