mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-08-18 22:14:37 +00:00
display fancy preview as a sprite on top of FlxG.stage, to properly render over substates
This commit is contained in:
parent
e24c78ae16
commit
0036a334bc
|
@ -92,9 +92,9 @@ class ScreenshotPlugin extends FlxBasic
|
||||||
flashColor: Preferences.flashingLights ? FlxColor.WHITE : null, // Was originally a black flash.
|
flashColor: Preferences.flashingLights ? FlxColor.WHITE : null, // Was originally a black flash.
|
||||||
|
|
||||||
// TODO: Add a way to configure screenshots from the options menu.
|
// TODO: Add a way to configure screenshots from the options menu.
|
||||||
hotkeys: [FlxKey.PRINTSCREEN],
|
hotkeys: [FlxKey.F3],
|
||||||
shouldHideMouse: false,
|
shouldHideMouse: false,
|
||||||
fancyPreview: true, // TODO: Fancy preview is broken on substates.
|
fancyPreview: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,43 +170,42 @@ class ScreenshotPlugin extends FlxBasic
|
||||||
|
|
||||||
static final PREVIEW_INITIAL_DELAY = 0.25; // How long before the preview starts fading in.
|
static final PREVIEW_INITIAL_DELAY = 0.25; // How long before the preview starts fading in.
|
||||||
static final PREVIEW_FADE_IN_DURATION = 0.3; // How long the preview takes to fade in.
|
static final PREVIEW_FADE_IN_DURATION = 0.3; // How long the preview takes to fade in.
|
||||||
static final PREVIEW_FADE_OUT_DELAY = 0.25; // How long the preview stays on screen.
|
static final PREVIEW_FADE_OUT_DELAY = 1.25; // How long the preview stays on screen.
|
||||||
static final PREVIEW_FADE_OUT_DURATION = 0.3; // How long the preview takes to fade out.
|
static final PREVIEW_FADE_OUT_DURATION = 0.3; // How long the preview takes to fade out.
|
||||||
|
|
||||||
function showFancyPreview(bitmap:Bitmap):Void
|
function showFancyPreview(bitmap:Bitmap):Void
|
||||||
{
|
{
|
||||||
// TODO: This function looks really nice but breaks substates.
|
var scale:Float = 0.25;
|
||||||
var targetCamera = new FlxCamera();
|
var w:Int = Std.int(bitmap.bitmapData.width * scale);
|
||||||
targetCamera.bgColor.alpha = 0; // Show the scene behind the camera.
|
var h:Int = Std.int(bitmap.bitmapData.height * scale);
|
||||||
FlxG.cameras.add(targetCamera);
|
|
||||||
|
|
||||||
var flxGraphic = FlxGraphic.fromBitmapData(bitmap.bitmapData, false, "screenshot", false);
|
var preview:BitmapData = new BitmapData(w, h, true);
|
||||||
|
var matrix:openfl.geom.Matrix = new openfl.geom.Matrix();
|
||||||
|
matrix.scale(scale, scale);
|
||||||
|
preview.draw(bitmap.bitmapData, matrix);
|
||||||
|
|
||||||
var preview = new FunkinSprite(0, 0);
|
var previewBitmap = new Bitmap(preview);
|
||||||
preview.frames = flxGraphic.imageFrame;
|
|
||||||
preview.setGraphicSize(bitmap.width / 4, bitmap.height / 4);
|
|
||||||
preview.x = FlxG.width - preview.width - 10;
|
|
||||||
preview.y = FlxG.height - preview.height - 10;
|
|
||||||
|
|
||||||
preview.alpha = 0.0;
|
FlxG.stage.addChild(previewBitmap);
|
||||||
preview.cameras = [targetCamera];
|
|
||||||
getCurrentState().add(preview);
|
previewBitmap.alpha = 0.0;
|
||||||
|
previewBitmap.y -= 10;
|
||||||
|
|
||||||
// Wait to fade in.
|
// Wait to fade in.
|
||||||
new FlxTimer().start(PREVIEW_INITIAL_DELAY, function(_) {
|
new FlxTimer().start(PREVIEW_INITIAL_DELAY, function(_) {
|
||||||
// Fade in.
|
// Fade in.
|
||||||
FlxTween.tween(preview, {alpha: 1.0}, PREVIEW_FADE_IN_DURATION,
|
FlxTween.tween(previewBitmap, {alpha: 1.0, y: 0}, PREVIEW_FADE_IN_DURATION,
|
||||||
{
|
{
|
||||||
ease: FlxEase.elasticOut,
|
ease: FlxEase.quartOut,
|
||||||
onComplete: function(_) {
|
onComplete: function(_) {
|
||||||
// Wait to fade out.
|
// Wait to fade out.
|
||||||
new FlxTimer().start(PREVIEW_FADE_OUT_DELAY, function(_) {
|
new FlxTimer().start(PREVIEW_FADE_OUT_DELAY, function(_) {
|
||||||
// Fade out.
|
// Fade out.
|
||||||
FlxTween.tween(preview, {alpha: 0.0}, PREVIEW_FADE_OUT_DURATION,
|
FlxTween.tween(previewBitmap, {alpha: 0.0, y: 10}, PREVIEW_FADE_OUT_DURATION,
|
||||||
{
|
{
|
||||||
ease: FlxEase.elasticIn,
|
ease: FlxEase.quartInOut,
|
||||||
onComplete: function(_) {
|
onComplete: function(_) {
|
||||||
preview.kill();
|
FlxG.stage.removeChild(previewBitmap);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue