What are the advantages/disadvantages of Canvas vs. DOM in JavaScript game development? [closed]

canvas
pros :

  1. could manipulate pixel and apply filter effect, so easy for image processing;
  2. very efficient for small size but hundreds of elements in the game
  3. many libraries for game could be found using canvas, such as box2dweb, and could make awesome games such as angry bird

cons:

  1. it’s stateless, so you have to record the states of the elements in the canvas, and handle the hit test by yourself.
  2. low efficient for very large size but with one a few elements in the game
  3. great ability, great responsibility. the freedom to draw, brings in you have to charge of all the drawing staff. Fortunately, there are many libraries there, such as cocos2d-html5, IvanK.

DOM
pros:

  1. rendering by the browser, so less error-prone;

cons:

  1. could do simple animation with CSS only, that makes the game not fluent;
  2. no good for manipulating hundreds of DOM elements;  

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)