Some original code from flixel-addons.
Make sure you have flixel
and openfl
installed.
Run the command:
haxelib install flixel-screenshot-plugin
To install a more bleeding-edge version (may be unstable), run this:
haxelib git flixel-screenshot-plugin http://github.com/sayofthelor/flixel-screenshot-plugin
In your Project.xml
make sure this is there:
<haxelib name="flixel-screenshot-plugin" />
In your project's Main.hx
file, after the FlxGame
is initialized, add this line:
flixel.FlxG.plugins.add(new screenshotplugin.ScreenShotPlugin());
And you're done!
If you want to save as a JPEG file instead, run this after the last line.
screenshotplugin.ScreenShotPlugin.saveFormat = JPEG;
The screenshot hotkey is an FlxKey, and is bound to F2 by default. You can change it like this:
screenshotplugin.ScreenShotPlugin.screenshotKey = FlxKey.Q;