Hi. When you hold down the minimize button or the close “x” button in the solar2D simulator for Windows, it is like crashing the application intentionally: transitions are pausing, but the timer.performWithDelay are still iterating its function🙂 I also see this in Samsung Galaxy J5, the app accidentally and unexpectedly crashes, and the timer.performWithDelay still iterate.
Try to run this code and then hold down the minimize or close button for a while and then release it,
local function Berserk ()
local bullet = display.newRect(display.contentCenterX, display.contentCenterY, 40, 20)
bullet.rotation = math.random(0, 360)
local rotationInRadians = bullet.rotation*math.pi/180
local travelDist = display.screenOriginY
local xDist = math.cos(rotationInRadians)*travelDist
local yDist = math.sin(rotationInRadians)*travelDist
local xDestination, yDestination = bullet.x + xDist, bullet.y + yDist
transition.to(bullet, {x = xDestination, y = yDestination, time = 200, onComplete = function() display.remove(bullet) end})
end
timer.performWithDelay(250, Berserk, 0)
How to predict this so that I can cancel the timer… and more. Please help me. Thank you very much.