我想在Android andengine中创建如下图所示的圆圈。它应该有box2d的body。我该如何创建它?
答案 0 :(得分:2)
由于提供的答案与实际问题完全无关,因此这里是实际答案:
您只需将文本实体附加到显示圆圈的精灵即可。
或者看看BitmapTextureAtlasSourceDecorators: https://github.com/nicolasgramlich/AndEngine/tree/GLES2/src/org/andengine/opengl/texture/atlas/bitmap/source/decorator。
关于从实体创建主体,请看这里: https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/PhysicsExample.java#L179
答案 1 :(得分:-1)
试试这个解决方案:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(demoview);
}
private class DemoView extends View{
public DemoView(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint p = new Paint();
p.setColor(Color.RED);
DashPathEffect dashPath = new DashPathEffect(new float[]{5,5}, (float)1.0);
p.setPathEffect(dashPath);
p.setStyle(Style.STROKE);
canvas.drawCircle(100, 100, 50, p);
Paint pp = new Paint();
pp.setColor(Color.BLUE);
canvas.drawText("kadir", 100, 100, pp);
invalidate();
}
}
}