1

I'm working on a tilemap implementation with blitting (in Flash but I don't think it's language relevant). The problem I'm having is that as I pan my camera around, 1 pixel seams start to become visible depending on the location.

Here's how I decide my blitting point:

var destination : Point = _position.toPoint();

if (camera != null)
{
    destination.x -= camera.position.x;
    destination.y -= camera.position.y;
}

// the actual blit, not really relevant:
canvas.bitmapData.copyPixels(_bitmapData, _sourceRectangle, destination, null, null, true);

As I scroll my camera around, I can see the position becoming really wonky. Here's some traces:

     pre-camera: 443 534
     post-camera: 396.3333333333333 294
     pre-camera: 476 534
     post-camera: 429.3333333333333 294
     pre-camera: 509 534
     post-camera: 462.3333333333333 294

The seams only appear with those .3333333333 post camera positions.

Does it seem logical that these floating point issues are what's causing the seams? Is it safe to just floor / round the destination values since you can't blit to half a pixel anyways.

Thanks!

  • This *is* completely related to how you're doing the blitting. – Arafangion Aug 24 '11 at 05:28
  • Well I included the copyPixels() command, but the only thing that changes between no visible seams and seams is the destinationPoint which I've shown how I calculate. Do you have an idea on what might be causing it? Thanks for your help so far. – Jessica O'Mally Aug 24 '11 at 05:33
  • 1
    I have noticed that when I have another flash instance running behind mine (like a youtube video) or even just another window, it would create seams. Since Number is a double, odds of this being a floating point error seem to be quite low (especially since you are only substracting). If not, is it possible that your positions don't line up? You could try to round your camera's position to an int when you draw your scene and see if that works – Godfather Aug 24 '11 at 06:34

0 Answers0