I want to create a circle like in picture below in Android andengine. It should have body by box2d. How can I create it?
Asked
Active
Viewed 1,207 times
2 Answers
2
Since the provided answers are completely irrelevant to the actually asked question, here the actual answer:
You can simply attach a Text entity to a Sprite that shows a circle.
Or have a look at the BitmapTextureAtlasSourceDecorators: https://github.com/nicolasgramlich/AndEngine/tree/GLES2/src/org/andengine/opengl/texture/atlas/bitmap/source/decorator .
- This Example will be particularly helpful: https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/CanvasTextureCompositingExample.java
Regarding creating a body from an Entity, have a look here: https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/PhysicsExample.java#L179

Nicolas Gramlich
- 2,790
- 19
- 19
-2
Try this solution:
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();
}
}
}

Cœur
- 37,241
- 25
- 195
- 267

Shankar Agarwal
- 34,573
- 7
- 66
- 64
-
try canvas.drawText(); function below drawcircle() – Apr 22 '12 at 09:21
-
it works.the my last request: how i can i make it as body(box2d)? – Kadir Apr 22 '12 at 09:42
-
"box2d pyhics engine" has a body elements.when you make two things as body, they can't stay the same place at the same time.namely they can collide not stay the same place. – Kadir Apr 22 '12 at 09:54
-
ok another question:i wanna change color of text? Paint p = new Paint(); p.setColor(Color.RED); p.setTextSize(50); canvas.drawCircle(100, 100, 50, p); canvas.drawText("kadir", 100, 100, p); invalidate(); – Kadir Apr 22 '12 at 09:59
-
p = new Paint(); p.setColor(Color.BLUE); canvas.drawText("kadir", 100, 100, p); – Apr 22 '12 at 10:03