我想在我的游戏中绘制自定义静态形状,就像愤怒的小鸟所做的那样:
I want to draw custom static shapes in my game just like the angry birds done:
但问题是纹理是方形的.
but the problem is that the texture is in square shape.
我们如何告诉SpriteBatch"绘制带有一些顶点的形状?有人有什么想法吗?
how we can tell to the "SpriteBatch" to draw shapes with some vertices? does anybody has some ideas?
根据文档:
SpriteBatch 用于绘制引用纹理(区域)的 2D 矩形
A SpriteBatch is used to draw 2D rectangles that reference a texture (region)
因此,从本质上讲,此方法不允许您指定除矩形之外的任何其他几何图形.但是,有一个 draw 方法 允许您指定矩形"的四个坐标并将其转换为其他东西.您必须将几何体分解为适合此基元的较小部分.看起来这种方法不适合几何形状的变化.
So essentially, this method does not allow you to specify any other geometry than a rectangle. However, there is a draw method that allows you to specify the four coordinates of the "rectangle" and turn it into something else. You'd've to decompose the geometry into smaller pieces that fits this primitives. Looks like this method doesn't lend itself to geometry changes.
最好创建一个网格然后画出来.网格不支持三角测量,所以使用 ObjLoader.loadObj* 方法在 Alias Wavefront OBJ 格式.指定几何图形不应该是一件麻烦事;文章链接到一些示例文件.
Better you create a mesh and just draw it. The mesh does not support triangulation, so use the ObjLoader.loadObj* methods to load a mesh in Alias Wavefront OBJ format. Specifying the geometry shouldn't be a hassle; the article links to some example files.
这篇关于如何使用 libgdx 中的简单纹理绘制自定义形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!