Page 1 of 1
Frames Per Second Best Practice
Posted: Tue Aug 26, 2014 9:06 am
by istech
Hi All,
I work with a lot of animations with LC and would like to get a better grasp of FPS in livecode and if my approach is correct and any optimization tips or links.
At the moment what I do is if I make a animation built with 12FPS and want to add it to a project I use the "send" command and divide 1000 by 12 which is 83.3 and send it to me. (1000ms = 1 second)
Is this approach a good practice? and what other methods do others use. thanks.
Re: Frames Per Second Best Practice
Posted: Tue Aug 26, 2014 11:28 am
by jmburnod
Hi Istech,
I understood the send command is better than repeat loop.
divide 1000 by 12 which is 83.3 and send it to me
I think you have to use round function to get an integer
The main problem for you is what doing during 4 milliseconds 1000-(83 * 12) = 4
Best regards
Jean-Marc
Re: Frames Per Second Best Practice
Posted: Tue Aug 26, 2014 2:03 pm
by MaxV
In videogame programming, no matter programming language you use, the best effect are cheating user senses.
If you need speed, sometime the best effect is to skip some animations. The classic example is the rolling wheel that go faster and faster:
- bad programmers write a cycle that rotate wheels of 1 degrees per cylce and speed up the cycle
- good programmers use always the same time for the cycle, but the increase the angle rotation per cycle
However a way is to build an animated GIF and use it. GIF are transparent and you may change:
no animation
Code: Select all
set the repeatCount of image "MyImage" to 0
infinite animation
Code: Select all
set the repeatCount of image "MyImage" to -1
just 3 animation loops
Code: Select all
set the repeatCount of image "MyImage" to 3
GIF speed is setted inside GIF, not by Livecode.
another way is to use
tick instead of seconds:
Code: Select all
send animationAdvaceOneFrame to me in 2 tick
but probably the last way is too fast, and it's difficult to control the
pendingMessages list.
Re: Frames Per Second Best Practice
Posted: Tue Sep 02, 2014 1:26 pm
by istech
MaxV wrote:In videogame programming, no matter programming language you use, the best effect are cheating user senses.
If you need speed, sometime the best effect is to skip some animations. The classic example is the rolling wheel that go faster and faster:
- bad programmers write a cycle that rotate wheels of 1 degrees per cylce and speed up the cycle
- good programmers use always the same time for the cycle, but the increase the angle rotation per cycle
Thanks for the useful info.