How to flash an Image & Spritemap white? [SOLVED]


(Darrin) #1

I may have solved this, lol 2 seconds after posting. I set

img.tintMode = 10

This seems to work, but no idea why… what is the range of the tintMode, what does it do?


When an enemy gets hit, I’d like to flash the whole image or spritemap to white for half a second. I tried colorizing with tinting using fairly bright colors like blue and yellow but they are still dull and hardly noticable. White would be best but doesn’t seem available.

This does nothing the closer it is to white (0xFFFFFF).

				img.color = 0xFCFCFC;
			img.tinting = 1.0;

Obviously there is an art solution, but seems like the code should be able to paint either the image or the mask. Or a temporarily fill in the bitmapdata or a copy of it (I recall there was some call for that)–but I wasn’t sure how that would work with a spritemap. Any suggestions?


(christopf) #2

When you check the declaration of tintMode its says 0 for multiply and 1 for colorize. So as you saying the effects only change slightly i guess you are still in multiply (what is default). Try to change tintMode to 1 instead of 10.


(JP Mortiboys) #3

To clarify a bit on image tinting:

  • tintMode changes the way that the colourisation is performed. Image.TINTING_MULTIPLY (which is 0) works in “multiply” mode - if you’ve used photoshop you’ll know this. Basically it will always make the image darker or the same, never lighter. Image.TINTING_COLORIZE (which is 1) is a straight-up colourise - mixing the source colour with the destination colour. tintMode can also be any number between 0 and 1, which will be a mixture of both effects. Technically it could be outside of this range too, but I’m not sure what that would look like or how useful it would be.

  • tintFactor indicates the power of the effect. 0 is no effect, 1 is 100% effect. Taking the example of TINTING_COLORIZE, tintFactor set to 0.5 would mean that each destination pixel colour would be the average of the source colour and the tint colour. tintFactor set to 1 would mean that each destination pixel colour would be set to the tint colour (which is precisely what Darrin is trying to do here)

It is possible to have tintFactor set outside the range of [0,1] - I seem to recall setting the tint colour to black and tintFactor to -1 made an interesting lighting effect.

An example of why you’d use each tintFactor:

If you want enemies to flash white or red when damaged, TINTMODE_COLORIZE is for you. At 100% there is no shading or texture visible on the enemy, they’re 100% white (or red). Photoshop analog is the “Color Overlay” layer effect in normal blending mode.

If you want a sprite to change colour but maintain shading, you need TINTMODE_MULTIPLY. Have the “main” colour as pure white and greys to indicate shadow/depth. Now when you apply the tinting with red (for example), all the white parts will become pure red, and all the greys darker red - shading is preserved.

When would you use an intermediate tintMode? No idea, but the option is there.