Hello
I'm sorry for my english.
Tell me who knows, I need to fill a polygon texture like this:

But i get this:

This my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| package com.absoft.balance.screen;
import java.util.ArrayList;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.PolygonRegion; import com.badlogic.gdx.graphics.g2d.PolygonSprite; import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.EarClippingTriangulator;
public class GameScreen implements Screen {
TextureRegion textureRegion; PolygonSpriteBatch batch; ArrayList<PolygonSprite> polygonSprites = new ArrayList<PolygonSprite>();
public GameScreen() {
batch = new PolygonSpriteBatch(); textureRegion = new TextureRegion(new Texture( Gdx.files.internal("123.png")));
float t = 0; float[] vertices = new float[] { 0 + t, 0 + t, 250 + t, 250 + t, 500 + t, 0 + t }; polygonSprites.add(new PolygonSprite(new PolygonRegion(textureRegion, vertices, new EarClippingTriangulator().computeTriangles( vertices).toArray())));
}
@Override public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); for (int i = 0; i < polygonSprites.size(); i++) { polygonSprites.get(i).draw(batch); } batch.end();
}
@Override public void resize(int width, int height) { }
@Override public void show() { }
@Override public void hide() { }
@Override public void resume() { }
@Override public void dispose() {
}
@Override public void pause() { }
} |
What do you think?? what i do wrong?