使用SVG文件libgdx [英] Using SVG files with libgdx

查看:444
本文介绍了使用SVG文件libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刨去创造平板电脑的应用程序为我的孩子,从图画书应用程序,但来自丰富的Web应用程序来的时候已经与Android / Java开发任何没有经验。

I'm planing to create tablet app for my kid, starting with coloring book app but coming from rich web apps I have no experience with android/java development whatsoever.

我会问一些指导: 我在SVG格式的图片像这样的: <一href="https://github.com/testeria/svgfiles/blob/master/roket.svg">https://github.com/testeria/svgfiles/blob/master/roket.svg

I would ask for some guidance: I have pictures in svg formats like this one: https://github.com/testeria/svgfiles/blob/master/roket.svg

使用SVG很容易,你只需要改变填充参数不同的颜色,但据我所知,没有一个简单的/稳定的SVG处理与libgdx使用(这是我的preferred框架)。 我还是想用SVG文件来为我的图画书创作/存储图像。

With SVG it is easy, You just change fill parameter to different color but as I understand, there is no easy/stable svg processing to use with libgdx (which is my preferred framework). I still want to use svg files to create/store images for my coloring book.

什么样的​​处理路径,你会推荐? 有没有一种简单的方法来转换为com.badlogic.gdx.math.bezier或多边形物体SVG路径/形状,然后绘制在屏幕上查看/获取用户输入(TAP)这里面的形状?或者我应该使用不同的对象/路径?

What processing path would You recommend? Is there an easy way to convert svg paths/shapes for com.badlogic.gdx.math.bezier or polygon objects and then draw them on screen/get user input (tap) inside this shapes? Or should I use different objects/path?

(形状也可以例如组合在一起,我想在一所房子两个窗口变色一次)

(Shapes could be grouped together for example I want two windows in a house to change color at once)

推荐答案

LibGDX写入的方式是它给你一个较低的水平的方式做这种类型的渲染,但不提供开箱即用的方式来呈现SVG。这真的取决于你正在寻找的东西,性能或只是单纯的想它来绘制基本形状。

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.

要简单地渲染形状,你可以使用类似的 ShapeRenderer 。它给你一个非常密切的接口Java2D的方式提请东西。也许可以快速得出一些基本的东西,这可能是方便的。

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.

如果你想要做一些更强大的版本的渲染,你可能会想看看使用的网眼和着色器的OpenGL ES工作。你可以找到的 LibGDX测试以及为例子/教程在网上搜索。

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.

如果你想打开SVG到纹理,你会想看看的像素图,然后你可以创建一个纹理与它渲染了Spritebatch。你将需要写你想要的颜色和这样的像素图的像素。不过,做这种方式会产生一个非托管的纹理(即您必须重建它,当用户回来后pressing应用程序背面或把设备睡眠)。

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).

希望这有助于。

这篇关于使用SVG文件libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆