HTML5 Canvas Performance: Loading Images vs Drawing

后端 未结 7 584
渐次进展
渐次进展 2021-02-04 08:23

I\'m planning on writing a game using javascript / canvas and I just had 1 question: What kind of performance considerations should I think about in regards to loading images vs

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 08:39

    As with most gaming considerations, you may want to look at what you need to do, and use a mixture of both.

    For example, if you are using a background image, then loading the bitmap makes sense, especially if you will crop it to fit in the canvas, but if you are making something that is dynamic then you will need to using the drawing API.

    If you target IE9 and FF4, for example, then on Windows you should get some good performance from drawing as they are taking advantage of the graphics card, but, for more general browsers you will want to perhaps look at using sprites, which will either be images you draw as part of the initialization and move, or load bitmapped images.

    It would help to know what type of game you are looking at, how dynamic the graphics will need to be, how large the bitmapped images would be, what type of framerate you are hoping for.

提交回复
热议问题