Overlaying Tiled Images...

Several people on this forum have been very helpful in clarifying how to overlay images to get a combined effect such as outlining a hexagonal tile with a highlighted color when the tile is selected.

Now I seem to have a different issue with such a process when I want a selected tile to be de-selected. In this case all of the code works fine but when a tile is redrawn after it has been de-selected, only the original base tile is draw without the highlighted overlay. What happens in this case is that it appears that a slight residue from the highlighted overlay appears to remain, though it was not drawn under these circumstances. Here are three images to demonstrate the issue…

No Tiles Selected

Three Tiles Selected

Three Tiles De-selected

Notice the slightly yellow residue from the original selection highlighting in the last image?

Any help with this issue will be greatly appreciated.

Thank you…


How is the highlight being applied (shader, etc.)?

Through overlaying the images with the highlighted outline having a transparent background. Use of the standard SpriteBatch.Draw method is used for the overlaying…

Are you clearing the backbuffer between frames? Any chance you are blending the new frame into the previous?

I don’t believe so about the blending of frames… :sweat:

However, I do not believe I am clearing anything with the back-buffer…

If you are not clearing the backbuffer, it is possible for textures with alpha to blend into the previous frame .

Are you calling something similar to “graphicsDevice.Clear(Color.Black);” before drawing each frame? What parameters are you passing to spriteBatch.Begin()?

Yes, I am calling the device clear method but only once, prior to building the map-board, which is created by laying each tile down at a specific set of coordinates.

I didn’t think that you had to do the clearing each time a tile was drawn to the display buffer…

You shouldn’t ever need to call the clearing method more than once per frame (just at the beginning of the “Draw” method). If you post your code we may be able to identify the cause.