views:

297

answers:

4

what are adventages and disadventages of creating games in 'pure' DOM and using canvas?

+1  A: 

With canvas you can perform operations such as rotation that you can't do with pure dome without use some "heavy" tricks. Anyway the dom is faster and you can use it in every browser without problems. You must think about what are you going to use in the game, if you will use only basic operations use the dom otherwise choose the canvas.

mck89
DOM is really faster? You're sure? I made simple pre-game engine with 2-3 moving elements in DOM and it was terrible. Ive never tried canvas, but examples i saw in internet was pretty much fast (faster then other DOM games i saw). Where i can read about that?
budzor
I'm absolutely sure. Think about the fact that canvas must manipulate a large amount of data.
mck89
Um, no, the common reason to use canvas is that it's faster than creating and modifying 1000s of DOM elements.
Nickolay
Yeah if you have 1000s dom elements, but i was talking about a simple interface. As i said in the answer if you want to use simple things (graphic included) choose the dom otherwise choose the canvas.
mck89
Anyway think about that the event management is very easy with dom elements while with canvas is more complicated.
mck89
A: 

Now, canvas very very slow and high cpu usage.

B11002
A: 

This blog post may be helpful. It compares Canvas vs DOM

http://blog.frontendforce.com/2010/03/games-development-in-javascript-canvas-vs-dom-benchmark/

Canvas is fast.

Drew LeSueur