How can I fill a circle in libgdx?

雨燕双飞 提交于 2019-12-24 13:44:15

问题


using the ShapeRenderer class, I can only fill rectangles.

  • So how can I fill a circle?
  • and if possible, fill a sector (portion of a circle)?

回答1:


As in the example of the shaperender

 shapeRenderer.begin(ShapeType.Filled);
 shapeRenderer.setColor(0, 1, 0, 1);
 shapeRenderer.rect(x, y, width, height); // fills a rect
 shapeRenderer.circle(x, y, radius);//<--- fills a circle
 shapeRenderer.end();

should fill the circle. How to get a portion of a cicle i have no clue. Maybe create a mesh and fill it or such like that. Take a look at the shaperender there are differnet methods to fill parts. Just check if some of them fit.




回答2:


For your second question, there is a method that fills only a portion of a circle

shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(0, 1, 0, 1);
shapeRenderer.arc(x, y, radius, start, degrees, segments); // Fills a portion of a circle
shapeRenderer.end();


来源:https://stackoverflow.com/questions/22272284/how-can-i-fill-a-circle-in-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!