Game Development Community

How do you change the color of sprites?

by George Schmitt · in Torque Game Builder · 05/06/2006 (10:42 am) · 1 replies

I want to be able to make sprites flash red, or turn green, etc. It would also be useful to be able to do dynamic spotlights, and effects that change the color of the whole screen (like a pulsing red warning light).
Is it possible to change tint like that dynamically in script, or do I have to learn how to write shaders?

#1
05/06/2006 (11:32 am)
You cannot easily use shader in TGB. But, depending on how fancy you want to get, your request is quite doable. For my current game, I have all white objects + alpha and I use .setBlendColor(%rgba) to determine what the color of the object will be on the screen.

I'm building a "team sport" style game, so the ability to have a basic player object that gets "rethemed" in color is important. Unfortunately, as TGB ships out of the box, there is no way to associate multiple textures with a single sprite and combine them with blending operations. I may add that as I get closer to "finishing" my game. In the meantime, .setBlendColor works fine.

It might work for you too. :-)