2011-12-16 16:37, Mikaël Gramont skrev:
Why not do something like this? Decoupling these two operations sounds
like a cleaner design.
// Like somebody said, 4ms is too fine of a resolution
setInterval(function gameflow() {
// This includes collission detection
move_all_objects_in_memory(); // DOM is left alone for SVG
}, 4);
// Use requestAnimationFrame instead
setInterval(function gameflow() {
move_all_objects_on_screen(); // DOM is updated for SVG
}, 16); // 60fps
Although one can use clearInterval to stop an ongoing animation, I
prefer just to stop the recursion.
A more complete library is coming soon to Github. Stay tuned.
--
Lars Gunther
http://keryx.se/
http://twitter.com/itpastorn/
http://itpastorn.blogspot.com/
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/
To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com