Backdrop creating a mysterious vertical line


(Helmi) #1

So I’ve got several horizontally looping backdrops, and every one has this weird vertical line somewhere on the right. The line is only visible on transparent backdrops, and the opacity of the line is based on the opacity of the image at that location:

It’s almost as if the backdrop is “overlapping” itself by 1 pixel there. Also this line is NOT at the edge of the images, and in fact it appears at different horizontal locations if I scale the graphics to different sizes. The line also disappears as the backdrop scrolls to the left.

If I carefully pan the camera 1-pixel left and right at the point where the line disappears and reappears, I can see that when there’s a line, 1 pixel of the image disappears under the line:

I’ve tried to rummage through the “Backdrop” class to figure out how it works (no luck), and I noticed that the line appears while “_point.x” is much less than zero, but once it reaches zero, that’s when the line disappears.

So… what the heck? Halp? :confounded:


Don’t know how useful my code is since this seems to happen no matter what I do, but here it is anyway: (I’m scaling the graphic, but I’ve tried without scaling and there’s no difference.)

public class SkyClouds extends Entity
{
	private var cloudsBG:Backdrop;
	
	//get the correct vector
	private var cloudsLevelClass:Class = getDefinitionByName("vector_clouds"+Global.cloudsState) as Class;
	private var clouds:MovieClip = new cloudsLevelClass();
	
	//new blank bitmap data, to draw the vector onto
	private var cloudsBMPDATA:BitmapData = new BitmapData(705 * Main.gameScale, 192 * Main.gameScale, true, 0x0);
	
	public function SkyClouds () //====== CONSTRUCTOR ==========
	{
		//draw the vector onto the bitmap data
		cloudsBMPDATA.draw(clouds, Main.graphicMatrix);

		//set the bitmap data as the backdrop			
		cloudsBG = new Backdrop(cloudsBMPDATA, true, false);
		
		graphic = cloudsBG; //set the backdrop as the graphic
		
	}
	
}

(Martí Angelats i Ribera) #2

This may be an error in the backdrop for negative values. Not sure though.


(Jacob Albano) #3

Is the error still present if you pass the class itself to the Backdrop constructor?

cloudsBG = new Backdrop(cloudsLevelClass, true, false);

(Helmi) #4

That doesn’t seem to be the case; if I move the backdrop right (or pan the camera left), the same thing happens. But instead of the line disappearing when _point.x goes from -1800 to zero, it happens when it goes from +1800 to zero. I suspect it has something to do with how Flashpunk resets the backdrop position when it loops around.

That just makes it invisible, probably because of how I’m drawing a vector to bitmapData. However if I import a graphic the traditional way and do this, it still has the line. :disappointed:

Also, SUPER WEIRD: if I use Flashpunk to adjust the alpha of the graphic (cloudsBG.alpha = .9;), the line rapidly fluctuates on and off as the camera scrolls, but then still disappears. W. T. F.


(Jacob Albano) #5

It’s quite possible this is an edge case that just exists in the Backdrop or Canvas rendering code. Can you upload your clouds image somewhere, or post the exact dimensions? I’d like to take a look and see if I can find the issue in the library code.


(Helmi) #6

This actually happens to all of my backdrops, not just the “clouds” one, and the exact dimensions don’t seem to matter, as long as the image is fairly large.

The cloud image is 705 by 192, and this is scaled up with a transform matrix to 1410 by 384. However the scaling isn’t the problem, as I’ve tested just having a larger image. Other backdrops are different sizes and the same thing occurs.

The game dimensions are also large; currently testing at 1920 by 900. The line didn’t appear until I started testing my game with larger screen sizes and thus larger backdrops.

(I greatly appreciate your taking a look; I’ve been trying to fix this silly thing for about a day now.)