UpdateScreen Handler??

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
drumdemon7GA727d
Posts: 14
Joined: Mon Dec 05, 2011 5:35 pm

UpdateScreen Handler??

Post by drumdemon7GA727d » Thu Dec 29, 2011 9:11 am

I was just wondering if there was anyway I could get the code so i can make the UpdateScreen handler work??
And I would also like to know how soon it would be until this code is implemented into LiveCode..

Thank You =]

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: UpdateScreen Handler??

Post by Klaus » Thu Dec 29, 2011 2:10 pm

What is a/the "UpdateScreen" handler?

drumdemon7GA727d
Posts: 14
Joined: Mon Dec 05, 2011 5:35 pm

Re: UpdateScreen Handler??

Post by drumdemon7GA727d » Sun Jan 22, 2012 12:32 am

In live code lesson 2, i think, he uses a handler called updatescreen and he copies a bunch of code into LiveCode so that itll work. But he says that we dotn have to worry about all that code because in the later versions of livecode, that code will already be implemented. I was just wondering when that code will be part of livecode so i can start writing games.

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm

Re: UpdateScreen Handler??

Post by kdjanz » Sun Jan 22, 2012 5:07 am

In the Game Academy forum David posted a link to the code you need:
http://forums.runrev.com/viewtopic.php? ... een#p47863

That's the forum where game talk is mostly taking place.

Kelly

raulvelazquez
Posts: 54
Joined: Fri Jan 20, 2012 6:08 pm

Re: UpdateScreen Handler??

Post by raulvelazquez » Mon Jan 23, 2012 5:46 am

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

Braleth
Posts: 4
Joined: Sun Apr 07, 2013 12:03 am

Re: UpdateScreen Handler??

Post by Braleth » Sun Apr 07, 2013 12:19 am

Apologies for the necro-post......

First time poster and brand new user of Live Code attempting to follow the first tutorial in the "Game Academy" series.

The above link is blocked and can not be accessed and the posted code doesn't work either as there is an error with line 16:
cancel sUpdateMessageId


Also worth noting is the tutorial files downloaded from here: www runrev com/thanks/game-academy-thank-you
do not seem to be complete. They simply contain the final code/finished product. I had to leverage google image search to locate a valid png of the rocket.

Is this an old link to the first game academy lesson with outdated material and video? Are the game academy lessons far more polished and functional in the paid version of game academy?

Any input from long time users is appreciated.

Thank you.

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

Re: UpdateScreen Handler??

Post by sturgis » Sun Apr 07, 2013 12:50 am

The code above is complete except for 1 thing. sUpdateMessageId is a script local variable but its not declared so it is treated as a temporary variable.

At the top of the script, add a declaration for all of the script local variables like so (very top of the script above all handlers)

Code: Select all

local sUpdateMessageId,sStartUpdateTime,sFrameRate
This should solve the issue. Currently, since its not declared, as soon as the handler ends it doesn't exist any more so the cancel message is trying to cancel "sUpdateMessageId" . Since it is not a variable, the engine treats it as a string.

Braleth
Posts: 4
Joined: Sun Apr 07, 2013 12:03 am

Re: UpdateScreen Handler??

Post by Braleth » Sun Apr 07, 2013 8:34 pm

Thanks for the reply, working great now. I also dug into the solutions for the first lesson and found the full code there as well.

Post Reply