Alright, currently in my project I'm rendering a tile, then rendering another tile that overlays onto the first and sort of provides tile based lighting. The first tile is the texture, then the second tile just has a black texture with the alpha value changed so that it can make the first tile lighter or darker. This isn't very efficient, however, because I have to render twice as many tiles for every tile space. The lighting in my game changes depending on the time of day, and the torches. So, is there anyway to tint the tiles texture using only one tile? I'm using LibGDX and my tiles are objects of the

1

Sprite

class. I'm not using shaders right now, but if I need to I can. Thanks!

with this you can set the opacity of the tile without change the color of it.I also think that if you add value to r,g and b channel you can change the darkness or lighter of your sprite, you can try.I hope this can help

with this you can set the opacity of the tile without change the color of it.I also think that if you add value to r,g and b channel you can change the darkness or lighter of your sprite, you can try.I hope this can help

dont forget the getColor part. The thing you do now is you draw it once with color, then you set the sprite color with no red green or blue elements in it. Meaning everything will be black.

Bumping because I have another question. Won't changing the tile's RGB values change the actual look of the tile? I feel like the image would look very distorted in terms of color, but if I used an overlay and just changed the alpha value according to the time of day, it might look better. Of course, I have no idea since I can't get the coloring code to work anyway. Any help would be appreciated!

Right, I know. Its just somewhere I heard someone say directly changing the RGB values of a texture looks different than actually using a separate mask. While your here though, could you venture a guess as to why my tiles aren't changing color?

When drawing a sprite, you should use the sprite.draw() method instead of the batch. I guess that this might be the reason why it is not getting tinted correctly.You could set the color for the batch too if you want.

That's the code from the official docs I only call sprite.setColor and batch.draw, I don't see how that's a bad thing to use both. Sprite.draw seems like it gives the same results as batch.draw, so why does it matter?

So, I was playing with my code, and I realized that the sprite only serves to render my texture. If I try to set the position of the sprite or rotate it or anything, it doesn't work. When I call sprite.draw(batch) and assign the sprites into a grid, the sprites still only render at coords 0, 0. I specifically set sprite.set position so I have no idea why that's not working. However, if I just draw the tiles like this:

It works fine and the tiles arrange into a grid. This is the first time I've used LibGDX, so I imagine this is a rookie mistake, but I really don't understand why working with the sprites doesn't work.

Well, I've discovered some more info. Every example code ive seen has a camera as well as a sprite. Do I need to have a camera to properly render a sprite? This doesn't make sense, but I'm grasping at straws here.

I re-read the thread a few times... If you're still having problems and would like help, pastebin or w/e your entire code, tell me what is going wrong and I will run it and have a go at fixing it as soon as I wake up

Ah! I love you this worked! Can you explain why though? If I set the zoom level to 0, I cannot see any tiles. Anything above 0, and it renders fine! I'm thinking that 0 means its fully zoomed in. Am I correct? Still, thank you so much!

Edit: also, I tried calling sprite.scroll and it did nothing. I increased the values of the scroll and then drew the tile, but it didn't do anything. However, sprite.setColor worked fine. Why is it only some sprite functions seem to work? :/

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org