LibGDX PolygonSprite与PolygonRegion

时间:2015-05-08 20:29:15

标签: java libgdx 2d polygon spritebatch

我可以使用PolygonSpriteBatch打印多边形,即:

Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pixmap.setColor(0x00CC00FF);     // DE is red, AD is green and BE is blue.
pixmap.fill();

Texture texture = new Texture(pixmap);
TextureRegion textureRegion = new TextureRegion(texture);
//textureRegion.flip(false, true);     //doesn't do anything =(

PolygonRegion polygonRegion = new PolygonRegion(textureRegion, polygonVertices, 
new short[] { 0, 1, 2, 0, 2, 3});    //triangle to fill in polygon

PolygonSprite polygonSprite = new PolygonSprite(polygonRegion);

PolygonSpriteBatch polygonSpriteBatch = new PolygonSpriteBatch();
我应该使用:

polygonSprite.draw(polySpriteBatch);

OR

polygonSpriteBatch.draw(polygonRegion, 0, 0);

以上两者都绘制了一个多边形,但我应该使用哪个?

另外,我如何翻转y轴以便从左上角而不是左下角画?

这一直困扰着我几个小时,tysm任何帮助。

0 个答案:

没有答案