Zarmeen Nasim
Zarmeen Nasim

Reputation: 23

How to place text on image in AndEngine?

I am new to android game development using andengine.

I am developing a game in which I have to use many different coloured balls.

What i want for improving the game performance is,that i should write random numbers on different balls programmatically?

Is it possible in andengine to add balls as an image and put numbers on top of it programmatically?

Upvotes: 2

Views: 416

Answers (1)

cjds
cjds

Reputation: 8426

There is a class in AndEngine called Text

Text objects act like entities and can be attached to a scene or another entity as a child

First you have to create a Font

Font mFont = FontFactory.create(this.getFontManager(), this.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32);
mFont.load();

Now create an object of text and add the text to the ball entity

Text text = new Text(0,0, font,"1");
ball.attachChild(text);

Here's a blog article that may help you more

Upvotes: 1

Related Questions