4
\$\begingroup\$

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();
this.getWindowManager().getDefaultDisplay().getMetrics(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

\$\endgroup\$
1

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ I used Tiled Editor for this.But I don't know how to add one pixel "gutter" between the cells. \$\endgroup\$
    – Bin
    Mar 8, 2013 at 4:47
  • \$\begingroup\$ 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) \$\endgroup\$ Mar 8, 2013 at 5:30
  • \$\begingroup\$ 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. \$\endgroup\$
    – Bin
    Mar 9, 2013 at 5:58
  • \$\begingroup\$ 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? \$\endgroup\$ Mar 9, 2013 at 12:48
0
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .