Tag: Pinball
Within the nme.geom package of Haxe NME you’ll find Matrices, Points, Vectors, Rectangles and… ColorTransform? It seems a slightly odd place to put it but it can be useful in your project to dynamically alter object colours. I wanted to talk briefly on how I’ve used it across my previous Pinball project and now, in Tower Defence.
Sometimes you want the same object to appear multiple times in your project, but with subtle variations. Behavioral changes can be accomplished in code by subclassing, size variations by scaling, but what if you wanted it red in one instance and green in another?
Including the same image twice with different colours feels redundant even if the images in question are quite small, so what are your options? In Pinball I used ColorTransform to colorize the lights and lighting effects with the image files themselves being greyscale. Now in Tower Defence I’m using it on some UI elements (the slider knob’s that change colour dependent on value).
Let’s step through how this works. First, of course, you have to create a graphic you want to use. Here’s the image of the slider knob in Tower Defence, as it came out of Photoshop…
Pinball was my first real project with NME, and influenced everything I’m doing with it now. It was very much an experimental project to gain understanding of how it all worked, and in retrospect, I wrote a lot of very heavy, slow code that was unnecessary.

Continue reading “Pinball”
