TMXTiledMap and setOpacity

TMXTiledMap and setOpacity
0.0 0


I have a TMXTiledMap and I’m trying to change its opacity but it won’t work.
Here is my code:

auto mapBackground = TMXTiledMap::create(mapName+".tmx");

Any help would be appreciated.


I did some searching and I found this. It says that it was filed as a bug but never said whether or not it was fixed so I’m assuming it wasn’t cause I still have the problem.


I will ask the engineering team for an update on this issue.


Thank you.


At this point, it has not been fixed. I have updated the issue with your feedback.


It has been a few months and I was wondering if there has been any updates on the issue.


I don’t think it has. I can ask again for an update.


@xxYxx I think you can change the opacity of each layer. so in such case that you want to set it to all layers just iterate through all of them and set opacity. can be a quick workaround for you.


I thought about this. It may work as desired!


I just tried changing the opacity of a layer and it does not work. However, this gave me the idea of trying just one tile which works. However, this feels extremely inefficient so I still believe that it should be fixed.


are you using Tiled to create the TMX ?

If you do, there is an option to set opacity for each layer in the tiled setup (not via code). did you try to see if setting it there works?

If it does work, I assume you may doing something wrong. but if it doesn’t it sound definitely like an issue.


I am using Tiled and for my TMX files and I can change the opacity in Tiled.
In case I am doing something wrong, this is how I’m changing the opacity in code



This is the logical way of doing it. TileMap can have many layers(Object Layer, SpriteLayer, tile layer) so if you try to do

It should not reduce opacity of whole object which is logically correct. What if developer only wants to reduce opacity of Object Layer or tile layer and keep the rest to default? and if one wants to modify whole map opacity then they should loop around the layers and set them individually, giving developers more flexibility in managing their layers.


@Lazy_Gamer he just said that applying to a layer doesn’t work. I did it as well now and I also can say it doesn’t work on my end.

@xxYxx you can try to look into the code and see how the TMXTiledMap is doing so. it may be that when he creates each tile it set its opacity.

Anyway, you can just inherit TMXTiledMap and override SetOpacitiy which will do just that. go over each tile and set its opacity.


I had not considered that. Lets try this.