I
I
Igor2016-08-08 11:02:52
JavaScript
Igor, 2016-08-08 11:02:52

Why does the game lag, will the canvas save if you use animated SVG in it?

isc.96.lt/t/gam/mar
Actually it is felt that the game slows down and does not go smoothly.
I'm thinking of using canvas instead of the usual html layout.
But in the canvas I think to use the same svg animated elements.
This kind of animation svg:
bd006eb716.jpg
If I use canvas, will it save the situation, and what are the mistakes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
napa3um, 2016-08-08
@napa3um

Canvas for raster graphics, not for SVG. Vector graphics will need to be converted to bitmap sprites before they can be used on canvas. But your problem is not in the way graphics are displayed, but in the way the ticks of the main loop are counted. To organize the cycle, use https://developer.mozilla.org/ru/docs/DOM/window.r... . A slightly more detailed description: html5.by/blog/what-is-requestanimationframe .

E
Elizaveta Borisova, 2016-08-08
@Elizaveta

setTimeout does not need to be combined with raf, but in general you can’t make a performance game on SVG.
canvas works with a raster, the same will not work.
For canvas, of course, try pixi and pixi-spine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question