2016-06-21 183 views
0

有3个圆形,每个圆形分为3个部分,其中指定了颜色,每个圆形应该朝相反的方向旋转。 enter image description here如何绘制圆形libgdx

+1

你准确的问题是什么?如何重现这张照片? – Deadpool

+0

@ Andromedae93 是的 – upward

+0

你有任何脚本来建议我们吗? – Deadpool

回答

0

好吧,你可以这样做使自定义弧和颜色分配给他们

如何使一个自定义的弧,而不从中心联是:

public Arc(Color color){ 
    this.color = new Color(color); 
    renderer = super.getRenderer(); 
} 

public Color getArcColor(){ 
    return color; 
} 


/** Draws an arc using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ 
public void arc (float x, float y, float radius, float start, float degrees,int segments) { 
    // int segments = (int)(6 * (float)Math.cbrt(radius) * (degrees/360.0f)); 

    if (segments <= 0) throw new IllegalArgumentException("segments must be > 0."); 
    float colorBits = color.toFloatBits(); 
    float theta = (2 * MathUtils.PI * (degrees/360.0f))/segments; 
    float cos = MathUtils.cos(theta); 
    float sin = MathUtils.sin(theta); 
    float cx = radius * MathUtils.cos(start * MathUtils.degreesToRadians); 
    float cy = radius * MathUtils.sin(start * MathUtils.degreesToRadians); 

    for (int i = 0; i < segments; i++) { 
     renderer.color(colorBits); 
     Gdx.gl.glLineWidth(width_of_line); 
     Gdx.gl.glEnable(GL20.GL_BLEND); 
     renderer.vertex(x + cx, y + cy, 0); 
     float temp = cx; 
     cx = cos * cx - sin * cy; 
     cy = sin * temp + cos * cy; 
     renderer.color(colorBits); 
     renderer.vertex(x + cx, y + cy, 0); 
    } 
} 

中的90段进行扫描让你的弧,现在如何使游戏画面 这些弧这样做是为了使电弧在你的代码

Arc a; 
    ... 
    ... 
    in create: 
a= new Arc(Color.RED); 
... 
in render: 
a.begin(ShapeRenderer.ShapeType.Line); 
a.arc(x,y, (float) radius, startangle, sweep, 100); 
a.end 

这会给你一个弧,它来旋转 改变你的startangle不改变你的扫描 像 startangle ++而不是startangle在上面的代码中,startangle被定义为 float startangle = 0;

希望这可以帮助