简体   繁体   English

如何绘制填充多边形? [安卓、Andengine]

[英]How to draw filled polygon ? [Android, Andengine]

I want to draw filled polygon in Andengine gles2.我想在 Andengine gles2 中绘制填充多边形。

I have vertices of polygon.我有多边形的顶点。 How I can draw it?我怎么能画出来? The problem is that it can have any number of vertices (4, 30).问题是它可以有任意数量的顶点 (4, 30)。

Next problem is that I want fill this polygon with my image(or just color if not possible).下一个问题是我想用我的图像填充这个多边形(或者如果不可能的话只填充颜色)。

Can' t find any function for this.找不到用于此的任何功能。 Is it possible ?是否可以 ?

This way you can create polygon with repeating image in it.通过这种方式,您可以创建带有重复图像的多边形。

final float offsetX = 0f;
final float offsetY = 115f;
final float[] vertexX1 = { 200f-offsetX, 400f-offsetX, 300f-offsetX, 200f-offsetX};
final float[] vertexY1 = { 200f-offsetY, 200f-offsetY, 300f-offsetY, 300f-offsetY};

final TexturedPolygon myRepeatingSpriteShape = new TexturedPolygon(offsetX, offsetY,       vertexX1, vertexY1, myTextureRegion, this.getVertexBufferObjectManager());
mScene.attachChild(myRepeatingSpriteShape);

This implementation was created by one of the community member recastrodiaz .此实现是由社区成员recastrodiaz之一创建的。 I think this will solve your problem.我认为这将解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM