Update screen

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Update screen

Post by maxs » Sat Feb 02, 2013 12:11 pm

Has Updatescreen been implemented in Livecode? I did not see it in the dictionary. Do I need to hunt done the code to paste into the stack script?

Max

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Update screen

Post by sturgis » Sat Feb 02, 2013 4:41 pm

Will need to hunt it down. If you have trouble finding it post here again and I'll start digging through my stuff to locate it.

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Update screen

Post by JosepM » Fri Apr 26, 2013 7:06 am

Hi,

I guess that isn't implemented yet. In the Game Academy you have the base stack to start from.

Salut,
Josep M

treefolk
Posts: 16
Joined: Tue May 21, 2013 10:54 pm

Re: Update screen

Post by treefolk » Mon Jul 01, 2013 7:20 pm

correct script with variables declared two comments down.\/
Last edited by treefolk on Sat Jul 20, 2013 10:39 pm, edited 1 time in total.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Update screen

Post by maxs » Tue Jul 02, 2013 10:40 am

Terrific!

This is great. This will really save me some time and effort.

Thanks.
Max

treefolk
Posts: 16
Joined: Tue May 21, 2013 10:54 pm

Re: Update screen

Post by treefolk » Tue Jul 02, 2013 8:20 pm

Hey, It looks to me like i left some of the code out, so here is the full update screen script:


local sStartUpdateTime
local sFrameRate
local sUpdateMessageId

on preOpenStack

set the acceleratedRendering of this stack to true
startUpdatingTheScreen 50

end preOpenStack

on activateScreenUpdates pFrameRate
if pFrameRate is empty then put 50 into pFrameRate
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

sorry for the double post, didn't wanna confuse anybody.

--treefolk

Post Reply

Return to “Games”