
Please I need help in this problem, how to make the game loop code works on mobile devices.
this code I try it but it doesn't work

Code: Select all
on moveObject
if the mouse is down then
if (the top of image "object" - 15) > 0 then
set the top of image "object" to (the top of image "object" - 15)
end if
else
if (the bottom of image "object" + 18) < the bottom of this card then
set the bottom of image "object" to (the bottom of image "object" + 18)
end if
end if
end moveObject
Code: Select all
local sStartUpdateTime
local sFrameRate
local sUpdateMessageId
on activateScreenUpdates
stopUpdatingTheScreen
startUpdatingTheScreen 50
end activateScreenUpdates
on startUpdatingTheScreen pFrameRate
put pFrameRate into sFrameRate
put 0 into sStartUpdateTime
send "dispatchUpdateScreen" to me in 0 millisecs
put the result into sUpdateMessageId
end startUpdatingTheScreen
on stopUpdatingTheScreen
if sUpdateMessageId is not empty then
cancel sUpdateMessageId
end if
put empty into sUpdateMessageId
end stopUpdatingTheScreen
on dispatchUpdateScreen
local tThisFrameTime
put the long seconds into tThisFrameTime
if sStartUpdateTime is 0 then
put the long seconds into sStartUpdateTime
end if
lock screen
dispatch "updateScreen" to this card with tThisFrameTime
unlock screen
local tTheTimeNow
put the long seconds into tTheTimeNow
local tNextFrameCount
put round((tTheTimeNow - sStartUpdateTime) * sFrameRate + 0.5) into tNextFrameCount
send "dispatchUpdateScreen" to me in (sStartUpdateTime + (tNextFrameCount * (1 / sFrameRate)) - tTheTimeNow) seconds
put the result into sUpdateMessageId
end dispatchUpdateScreen