简体   繁体   中英

How to draw filled polygon ? [Android, Andengine]

I want to draw filled polygon in 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).

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 . I think this will solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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