The delay didn’t make a difference. Here is the core of the problematic code… it is a module loaded by director class. The code places a button on the screen and then counts down from 7. If you press the button and hold it while the Alert pops up… and then hit the RETURN key to simulate simultaneous selection of YES… it crashes. This crashes in both the simulator and on a iphone 3GS.
Any ideas? Thanks!
[code]
module(…, package.seeall)
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
local gameOver=0
local gameTime=0
local gameDuration=7
local score=11
– display timer text on screen
local textObject = display.newText( “0”, 100, 30, “Courier”, 20 )
textObject:setTextColor( 255,215,175 )
textObject:setReferencePoint(display.CenterLeftReferencePoint)
localGroup:insert(textObject)
textObject.text ="SHOT CLOCK: "…gameDuration-gameTime
local timeCheck = {}
function timeCheck:timer( event )
gameTime=gameTime+1
if (gameDuration-gameTime)>=10 then
textObject.text ="SHOT CLOCK: "…gameDuration-gameTime
end
if (gameDuration-gameTime)<10 then
textObject.text =“SHOT CLOCK: 0”…gameDuration-gameTime
end
if ( gameDuration-gameTime==0 ) then
timer.cancel(t2)
playAgain()
end
end
– start timer
t2 =timer.performWithDelay(1000, timeCheck, 0)
– ####### BUTTON PRESS HANDLER #######
local mainButtonHandler = function( event )
------enter code here ----
end
– Define Main Button
local buttonMain = ui.newButton{
default = “images/button_2.png”,
over = “images/button_1.png”,
onEvent = mainButtonHandler,
id = “pushbutton”,
text = “Press”,
size = 30,
textColor = { 255, 255, 255, 255 },
emboss = true
}
buttonMain.x = (display.contentWidth / 2)-2
buttonMain.y = 440
localGroup:insert(buttonMain)
– ####### PLAY AGAIN? #######
local function onComplete( event )
if “clicked” == event.action then
if 2 == event.index then
unloadThenMenu()
end
if 1 == event.index then
unloadThenReplay()
end
end
end
playAgain = function()
gameOver=1
print(“PLAY AGAIN”)
– show alert
if score~=0 then
print(“PLAY AGAIN”)
local alert = native.showAlert( “You made baskets in “…gameDuration…” seconds!”, “Play Again?”, { “YES”, “NO” }, onComplete )
print(“PLAY AGAIN”)
else
local alert = native.showAlert( “Good Try!”, “Play Again?”, { “YES”, “NO” }, onComplete )
end
print(“PLAY AGAIN”)
end
– ####### UNLOAD & RE-PLAY #######
unloadThenReplay = function()
– REMOVE EVENT LISTENERS
– REMOVE everything in other groups
for i = localGroup.numChildren,1,-1 do
local child = localGroup[i]
child.parent:remove( child )
child = nil
end
director:changeScene(“game_shot_clock_loader”)
end
– ####### UNLOAD & BACK TO MENU #######
unloadThenMenu = function()
– REMOVE EVENT LISTENERS
– REMOVE everything in other groups
for i = localGroup.numChildren,1,-1 do
local child = localGroup[i]
child.parent:remove( child )
child = nil
end
director:changeScene(“game_menu”)
end [import]uid: 16901 topic_id: 6738 reply_id: 23734[/import]