Hi you all, I’m using the following code to do a “game over” feature of my game:
[lua]
local statusText = display.newText("", _W/2, _H/2-100, “PUSAB”, 26)
local timeText = display.newText("", _W/2, _H/2, “PUSAB”, 26)
local function adjustText()
if player.y > _H then
statusText.text = “Game Over”
media.playSound( “suoni/gameover.wav” )
local function replacePlayer()
player:removeSelf()
player = nil
end
timer.performWithDelay( 100, replacePlayer )
statusText:setTextColor(255, 255, 0)
Runtime:removeEventListener(“enterFrame”, scroll)
else
statusText.text = “”
end
end
Runtime:addEventListener(“enterFrame”, adjustText)
[/lua]
It works fine, the problem is that once player.y is higher than the screen height I get
[lua]
File: …nzoestienne/Desktop/prova director/gameWithSound.lua
Line: 114
Attempt to index upvalue ‘player’ (a nil value)
stack traceback:
[C]: ?
…nzoestienne/Desktop/prova director/gameWithSound.lua:114: in function <…nzoestienne/Desktop/prova director/gameWithSound.lua:112>
?: in function <?:218>
[/lua]
How can I fix this problem?
Thanks!! 