I have soldiers, and to distinguish enemy from friendly, I decided to color them respectively blue and red.
This is simple if it's a sprite via draw.setColor but how would I go about a spriteBatch? (one batch can have both colored units)
Coloring a spriteBatch sprite
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Coloring a spriteBatch sprite
Like love.graphics.setColor does without SpriteBatches, SpriteBatch:setColor affects the colour of the sprites added after the call.
Re: Coloring a spriteBatch sprite
Doing SpriteBatch:setColor will alter the color of all the next sprites you set/add in the batch; similar to how love.graphics.setColor works.
Documentation here:
https://love2d.org/wiki/SpriteBatch:setColor
Documentation here:
https://love2d.org/wiki/SpriteBatch:setColor
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Coloring a spriteBatch sprite
Damn! Thanks, I didn't see that!
I knew there was a way..
EDIT: Is it possible to achieve something like this code-wise ?
I knew there was a way..
EDIT: Is it possible to achieve something like this code-wise ?
Re: Coloring a spriteBatch sprite
Sure!
First, the sprite you want to edit needs to be white so the color will apply correctly.
If you want to color a sprite partially, you have to separate it into multiple.
You can edit the color with just RGB(A) values. But if you really want HSV you can look into converting it.
https://gist.github.com/raingloom/3cb61 ... caa326a25a
First, the sprite you want to edit needs to be white so the color will apply correctly.
If you want to color a sprite partially, you have to separate it into multiple.
You can edit the color with just RGB(A) values. But if you really want HSV you can look into converting it.
https://gist.github.com/raingloom/3cb61 ... caa326a25a
Who is online
Users browsing this forum: Google [Bot] and 206 guests