Page 1 of 1

How to make this code works on mobile devices?

Posted: Wed Feb 13, 2013 1:11 pm
by ahmedinvent24BUSGdU9
Hi all, :)

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
      
and the stack code is

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
Please help me, how to make this code works on mobile devices?!

Re: How to make this code works on mobile devices?

Posted: Wed Feb 13, 2013 6:38 pm
by jmburnod
Hi ahmedinvent24BUSGdU9,

Here is a little stack with a move pending message.
Inch'Allah i hope this help.

Best regards
Jean-Marc

Re: How to make this code works on mobile devices?

Posted: Wed Feb 13, 2013 10:13 pm
by ahmedinvent24BUSGdU9
Thank You very much Jean-Marc :) :)
Thats really works!

Thank You :)

Best Regards
Ahmed F. :)