Jump to content

Mapping tint color to a variable


Conqarous
 Share

Recommended Posts

Hey, maybe someone solved this problem before.

 

Lets say I have a variable from 0 to 100.

How can I map it to the tint color for the sprite?

 

I.e.:

when variable is at 0 -> sprite.tint = white;

[everything in between]

when variable is at maximum (100) -> sprite.tint = red;

 

Thanks!

 

Link to comment
Share on other sites

what are the colours in between?

 

you cant tint a sprite white, so i assume you just mean a tint of 0xFFFFFF which will show it's original colour

 

i've used HSLtoRGB to do Black to Red to White tint which isn't quite what you want though

http://phaser.io/sandbox/fiSAdnSD/play

 

(maybe 50 to 100% lightness covers what you need, so you can fix it up with a bit of maths to map to your original range... in which case try ths http://phaser.io/sandbox/viiUTUex/play )

 

If you could clarify exactly what you need though.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...