Not all characters are shown when using MenuScene

These days I was studying how to use the AndEngine‘s MenuScene. What is this good for? It’s good to make a menu with floating text over the screen, as shown in picture 1. It looks nice, doesn’t it?

Picture 1 – Menu options using MenuScene

I’ve used this example from AndEngine. This example built a menu with just 2 options (2 strings: RESET and QUIT). At first everything worked fine.

Then I changed it a little to have 4 options: “Option 1“,  “Option 2“, “Option 3” and Quit“.  In other words, it now had 4 strings.

To my surprise instead of the menu shown on picture 1 I got the one shown in picture 2.

Picure 2 – Menu option with some characters missing

To make a long story short, I discovered that the texture size used to hold the font was too small.

The original code was

and I changed it to

So if you ever encounter this problem you already know what to do.

Note:  Texture width and height must be power of two, so the next value greater than 256 was 512. If 512 was not enough the next value would be 1024.

I still need to figure out how to determine the Texture dimensions based in the font and text that I want to use, but this trial and error method is enough for the moment.

Please, try my games, play free on-line games on my site, tweet this post url and share it on facebook, google+ and other social medias.

This entry was posted in andengine, android and tagged , . Bookmark the permalink.