Share Posted July 14, 2013 In the docs the "ticker" property is defined as 'The object that dispatches a "tick" event each time the engine updates,..' Can anyone tell me the frequency of engine updates(for both AS and Javascript)? For example are there 60 "ticks" per second? 30? Is it strictly enforced or does it vary? Also is there any way to specify the number of engine updates per second? Thanks, Jeff Link to comment Share on other sites More sharing options...
Author Share Posted July 14, 2013 I've had time to do a bit more searching and I found a codepen page See the Pen lEiAv by GreenSock (@GreenSock) on CodePen that has this bit of code at the beginning of the .js TweenLite.ticker.fps(60); So it does look like you can specify frames per second, though I've yet to find any reference to this in the docs, -J Link to comment Share on other sites More sharing options...
Share Posted July 14, 2013 Hi Jeff and welcome to the forums. The engine indeed updates 60 times per second, because it runs on the Request Animation Frame method, you can read more in the following posts: http://forums.greensock.com/topic/6811-tween-engine-always-running/ http://forums.greensock.com/topic/6773-requestanimationframe-ticker-keeps-on-going/ As far as specify the fps I believe that is not possible, but I'm not completely sure about it. Anyway I wouldn't recommend it because it could create an unexpected behaviour because basically if the ticker is working with the RAF method and it might disturb the proper function of it, but I leave it to Jack and/or Carl so they can give you a more complete answer. On a side note I'm very curious on why would you want to change the fps of the engine. Here you can read a little more about the RAF and it's intricacies: http://creativejs.com/resources/requestanimationframe/ Hope this helps, Cheers, Rodrigo. Link to comment Share on other sites More sharing options...
Share Posted July 15, 2013 Just to clarify, yes, you can set the framerate via TweenLite.ticker.fps(someNumber) And yes, we should probably make note of this in the docs. -c Link to comment Share on other sites More sharing options...
Author Share Posted July 15, 2013 On why I would want to change the fps of the engine. I'm looking into using Greensock to generate and sequence some target parameters for a box2D physics simulation. If the default update frequency didn't match the simulation's timestep, it might cause some issues and changing Greensock's fps rather than the sims fps/timestep would be the preferred solution. The good news is the sim's fps is also 60, so that matches and things are at least heading in the right direction. Browser animation is something I've not really dealt with before. My experience is with content creation stuff not web stuff; case in point, I was completely unaware of requestAnimationFrame which seems pretty darned important. Lots of good info for me to chew on here, and that's much appreciated. Thanks, -Jeff Link to comment Share on other sites More sharing options...
Share Posted July 16, 2013 Just for the record, when using requestAnimationFrame, the fps() setting acts like a throttle. Since you cannot tell the browser to crank out requestAnimationFrames at a higher rate than 60fps, you can't do something like TweenLite.ticker.fps(100). But you could do TweenLite.ticker.fps(30) and the engine will skip beats when necessary in order to get you as close as possible to 30fps (or whatever fps you set below 60). If you need something higher than 60fps (which I wouldn't really recommend generally), you could turn off requestAnimationFrame functionality in the ticker like this: TweenLite.ticker.useRAF(false) That'll cause it to use a regular setTimout() loop instead. But in general, I'd definitely recommend sticking with the default requestAnimationFrame as it typically yields best performance due to synchronizing with when the browser is doing paints. Happy tweening! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now