0

The physics engine Matter.js (https://brm.io/matter-js/docs/index.html) allows bodies to have a sprites but if it's a gif it doesn't animate.

Why is that? → https://brm.io/matter-js/docs/files/src_render_Render.js.html

ggorlen
  • 44,755
  • 7
  • 76
  • 106
Calvin
  • 194
  • 17
  • Does this answer your question? [Animated GIF in HTML5 canvas](https://stackoverflow.com/questions/3062229/animated-gif-in-html5-canvas) – ggorlen Jan 04 '21 at 19:27
  • MJS offers a basic renderer that is "mostly intended for development and debugging purposes" (quoting the [docs](https://github.com/liabru/matter-js/wiki/Rendering)). This renderer supports images but fundamentally, it's a wrapper on plain old HTML5 canvas. As such, it handles gifs exactly the same as [HTML5 canvas does](https://stackoverflow.com/questions/3062229/animated-gif-in-html5-canvas), so the question pretty much reduces to "why doesn't HTML5 canvas display a gif? – ggorlen Jan 04 '21 at 21:32
  • One solution is to flatten the gif frames onto a sprite sheet, at which point you can use an approach like [this answer](https://stackoverflow.com/questions/65207865/matter-js-is-there-any-way-to-animate-my-sprite/65301374#65301374) to show the animation. – ggorlen Jan 04 '21 at 21:32
  • 1
    Thanks @ggorlen I also contacted the creator, the render is very simples and not meant to actual do complex stuff. So I need another solution, and use MJS just for physics – Calvin Jan 04 '21 at 22:34

0 Answers0