Using SVG files with libgdx

前端 未结 1 1959
情歌与酒
情歌与酒 2021-02-19 09:17

I\'m planing to create tablet app. I would ask for some guidance.

I have pictures in SVG format like this one.

With SVG it is easy, You just change fill paramete

1条回答
  •  情书的邮戳
    2021-02-19 09:52

    The way LibGDX is written is it gives you a lower level way to do this type of rendering, but doesn't offer out of box ways to render SVG. It really depends on if you are looking for something with performance or just simply want it to draw basic shapes.

    To simply render shapes you could use something like ShapeRenderer. Which gives you a very close interface to the Java2D way to draw things. Maybe to quickly draw some basic stuff this might be handy.

    If you are wanting to do some more robust version of rendering you will probably want to look into using a Mesh and working with shaders for OpenGL ES. You can find examples of these in the LibGDX tests as well as searching online for examples/tutorials.

    If you want to turn the SVG into a texture you will want to look at Pixmap and then you can create a Texture with it and render with a Spritebatch. You will need to write the pixels you want to color and such with the Pixmap. However, doing it this way will generate an unmanaged texture (i.e. you will have to rebuild it when a user comes back to the app after pressing back or putting the device to sleep).

    0 讨论(0)
提交回复
热议问题