Flixel Power Tools FlxSpecialFX

Back to the Flixel Power Tools

The more I worked on the Power Tools the more I realised they were splitting into two key areas: tools for your game, and tools that created visual effects. So it made sense to me to start splitting them out – which is where the FlxSpecialFX class comes in.

It’s a handler for the new FX Plugin system, into which I’ll carry on expanding and adding new FX (and hopefully the community will too!). Here is example code for using the Rainbow Line plugin:

Code Example

// line1 is a RainbowLineFX object, returned by the FlxSpecialFX handler
line1 = FlxSpecialFX.rainbowLine();
// Creates the effect, setting some coordinate, width, height and speed parameters
line1.create(0, 0, 320, 1, null, 360, 4);
// Finally its added to the display
add(line1.sprite);

and here is how to create a star field:


// Creates a 2D scrolling starfield with 200 stars in it, the full screen size
stars = new FlxStarField(0, 0, FlxG.width, FlxG.height, 200, 1);
// Tells the stars to not move horizontally, but move 0.5 verticall (i.e. down the screen)
stars.setStarSpeed(0, 0.5);

The FX plugins work a little differently in that you don’t instantiate them directly, but rather get a new instance from the FlxSpecialFX manager – the manager is responsible for updating the effects and general house keeping (safe destruction on State change for example).

Special FX Plugins List

Here are the FX plugins available so far:

BlurFX

Creates a nice blur trail based on whatever sprites you feed to it. You can control the speed at which it blurs, the blur size and the blur quality.

CenterSlideFX

Makes an image appear (or vanish) from its center point. The two halves slide open, either vertically or horizontally. And can hide again after display.

FloodFillFX

Creates an interesting way to reveal a title page or in-game element, by dropping all of the pixels down until the picture is complete. Control over the speed and size of drop

GlitchFX

Makes a sprite glitch – like static or TV distortion across it horizontally. You can control the size and intensity of the glitch and run it in real-time.

PlasmaFX

Creates a large block of colour cycling swirling plasma. You control the size of the effect and the colours used, even the alpha range per colour which can look lovely when applied over the top of an image. More controls are coming shortly.

RainbowLineFX

Creates a scrolling colourful line that can shoot across the screen. A pretty effect for topping and tailing images for example (as in the screen shot below). You have full control over the colours used in the line, if it should fade in/out or not, the alpha level, the direction and the “chunk” size of it.

SineWaveFX

This is a powerful effect! It will sine-wave a sprite either horizontally or vertically. You can complete control over the effect – from the strength and duration of the wave, to the number of “chunks” it will shift. It can even distort a live image, that is one that is currently updating – for example you could feed an FlxScrollText into the SineWave and it will ripple it in real-time! Multiple waves can be fed into each other, allowing for some very trippy effects. Very powerful indeed!

StarFieldFX

FlxStarField is a parallax-scrolling starfield class for creating rich backdrops, ideally suited to shoot-em-up games. You can control the position, width and height of the starfield. As well as how many layers it has, the colour of each layer, the quantity of stars, their direction/speed and if the starfield is 2D or 3D. In a 3D starfield the stars come from the center of the field out towards you. On a 2D field they move typically horizontally, although you have fine-grained control over the x and y increments, so you can make them move in literally any direction you like. You can also customise the background (from fully transparent to any colour).

Recent Flixel Power Tool Posts

  1. Flixel Power Tools v1.9 Released
  2. Flixel Power Tools v1.8 Released - Let's get clicky
  3. Flixel Power Tools v1.7 - Kaboom!
  4. Flixel Power Tools v1.6 released including FlxControl
  5. Flixel Power Tools v1.5 - A monster of an update!
  6. FlxScreenGrab and FlxScrollZone added to Flixel Power Tools
  7. Flixel Power Tools v1.3 - Now Flixel 2.5 compatible!
  8. FlxHealthBar added to Flixel Power Tools

Make yourself heard