Monday, June 06, 2011

Tinting in ImpactJS, Part 3

So, it seems that some people are reading this blog. Which is nice.

Recently, I was asked to come up with an example for usage of my ImpactJs tinting plugin (downloadable here).

Well the first prerequisite for usage is to own ImpactJS, which is purchasable from here. When you have this installed and configured correctly, then you can drop the imageTinter.js into the ImpactJS plugins directory.

Once this is done, make sure you add 'plugins.imageTinter' to the requirements section of your main game class.

From there, you will be able to use various overloaded forms of the init method for ig.AnimationSheet and ig.Image that allow you to specify a tint color and tint alpha. Support is also provided for tinting a background map using setLayerTint method of the ig.BackgroundMap class.

Note: As long as any new images are instantiated as part of the init methods of the respective owning classes (rather than instantiated prior to the init method) then the images should be stored in the ImpactJS-provided image cache using a tint-friendly key format.

There is still some manual plumbing that needs to be done by the developer to fully integrate the tinting into ImpactJS, but this should certainly be enough to get started.


N said...

I've added the imageTinter plugin to the requirements section of my main game class. Where and how do I set the tint of a level? (level was created in Weltmeister btw)

N said...

Okay, my browser's error console reads 'Missing name after . operator' LevelCave001.layer.'floor'.setLayerTint('deeppink');

I know I'm close. What should my line read to use 'setLayerTint'?

Also, is there a way to simply set the entire level's tint, without setting each layer's one at a time?

Thanks for the great plugin!