Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used AndEngine gles1 along with the tmx plugin to generate my background maps. The image width is not fit to my virtual device, so I increased the tmx image size. Here is my code for the camera width and Camera Height:

CAMERA_HEIGHT = 320;        
final DisplayMetrics displayMetrics = new DisplayMetrics();
float aspectRatio = (float) displayMetrics.widthPixels / (float) displayMetrics.heightPixels;
CAMERA_WIDTH = Math.round(aspectRatio * CAMERA_HEIGHT);

But it shows me black bars as follows:Image Having Black Bar

share|improve this question
For camera calculation you have to use this answer…. For other question answer you have to try other options of TextureOption. – Siddharth Mar 7 '13 at 17:36

I ran into the same problem, and I don't believe that those black bars are caused by the way you're calculating your camera. For some reason, the way AndEngine and its TMX plugin handle sprite sheets causes artifacts like that unless your sprite sheet is designed with at least a one pixel "gutter" between the cells. I reworked the spritesheet using this gimp plugin and that fixed the issue.

share|improve this answer
I used Tiled Editor for this.But I don't know how to add one pixel "gutter" between the cells. – Bin Mar 8 '13 at 4:47
I'd recommend installing gimp (it's free, similar to photoshop), and installing the plugin I linked to (also free). It adds a gutter to the cells. You can still use Tiled Editor to make the maps, you'll just need to tell it your sprite sheet has a gutter (there's an option when you add the sprite map) – Cameron Fredman Mar 8 '13 at 5:30
Thanks for your suggestion It has nice documentation and I install it but I don't know how to make TMX image in it. I make images in Tiled Editor so it is convenient for me to make images in it.When I add new sprite map at that time I didn't found any gutter option. – Bin Mar 9 '13 at 5:58
Tiled editor doesn't make images, it makes XML files. I still want you to use Tiled to make the XML, I'm just suggesting you edit the spritesheet (images) using gimp, and using the plugin I linked to, then read those images into Tiled. Which part of this isn't making sense? – Cameron Fredman Mar 9 '13 at 12:48
Ok.. Now I got it.! Thanks. – Bin Mar 10 '13 at 6:59

Other option is to use this fixer provided by Nicolas. You need to download the code and compile it. Due to the nature of the fixer, don't use it if you tiles use any alpha channel.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.