• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Best practice for Canvas Object Game Refresh display?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When creating games in javascript manipulating people, objects, trees on the screen is a must but what's the best practice? Is it usually best to have a setTimeout or requestAnimationFrame that continually updates everything, clearing the screen and then recreating everything all over again? Whats the best way to do this? Seems like this would be intensive.

Also are there any libraries you'd recommend using? or just starting from scratch?

I've been looking at three.js, mrdoob has some cool little examples.
 
author
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

requestAnimationFrame is better that setTimeout. It's implemented on most modern browsers. I currently use Paul Irish(Dev Rel for Chrome at Google)'s requestAnimationFrame shim. It handles the different signatures of requestAnimationFrame, as it is not yet a standard, and falls back to setTimeout if requestAnimationFrame is not available.

Three.js is a great library for 3D but it is important to know the fundamentals first so that you are not captive to a single library and can transfer skills.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic