UpdateScreen Handler??
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 14
- Joined: Mon Dec 05, 2011 5:35 pm
UpdateScreen Handler??
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 =]
And I would also like to know how soon it would be until this code is implemented into LiveCode..
Thank You =]
Re: UpdateScreen Handler??
What is a/the "UpdateScreen" handler?
-
- Posts: 14
- Joined: Mon Dec 05, 2011 5:35 pm
Re: UpdateScreen Handler??
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.
Re: UpdateScreen Handler??
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
http://forums.runrev.com/viewtopic.php? ... een#p47863
That's the forum where game talk is mostly taking place.
Kelly
-
- Posts: 54
- Joined: Fri Jan 20, 2012 6:08 pm
Re: UpdateScreen Handler??
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
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
Re: UpdateScreen Handler??
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.
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.
Re: UpdateScreen Handler??
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)
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.
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
Re: UpdateScreen Handler??
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.