java - LibGdx Polygon.getTransformedVerticies() not returning the array -


i have quite simple problem makes no sense me.

i have method drawstar() in helper class:

public void drawstar(star star) {       shaperenderer.begin(shapetype.line);      shaperenderer.setcolor(color.red);      poly[star.id].setvertices(star.verticesstar);      if(star.rotation > 0){          poly[star.id].rotate(star.rotation);          poly[star.id].setorigin(star.originx, star.originy);          shaperenderer.polygon(poly[star.id].gettransformedvertices());       }else if(star.rotation == 0){          shaperenderer.polygon(star.verticiesstar);      }      shaperenderer.end();      system.out.println(poly[1].gettransformedvertices()[5]); //works fine } 

the above takes dimensions , vertices of star object pass , draws accurately array of polygons. there no problems @ stage.

the problem when try access polygon array in class, example:

polygon[] poly = new polygon[50]; poly = helper.poly; system.out.println(poly[1].gettransformedvertices()[5]); //says array indexoutofbounds 

i can print out poly[1].gettransformedvertices().length , accurately return 20 size of vertices array of star , same answer both in helper class , other class, when attempt print out 1 of these vertices individually in other class array indexoutofbounds.

additional debugging in other class, works:

    for(int = 0; < helper.poly[1].gettransformedvertices().length; i++){         system.out.println(helper.poly[1].gettransformedvertices()[1]); //0-19 works fine index     } 

but fails:

    system.out.println(helper.poly[1].gettransformedvertices()[1]); //0-19 returns indexoutofbounds 

why loop accurately return transformed vertices, exact same variable outside loop fails , says array index out of bounds? if helper.poly[1].gettransformedvertices().length returns 20, indicated array size 20, why helper.poly[1].gettransformedvertices()[1] fail? , works inside loop?

any appreciated.

i figured out, polygon.gettransformedverticies() in update method array size of 0 , populate itself, loop work when array populated brute forcing index wouldnt work. added line , worked fine.

    if(poly.gettransformedvertices().length != 0){         system.out.println(poly.gettransformedvertices()[0]);     } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -