mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-22 23:57:50 -05:00
Merge pull request #411 from FunkinCrew/feature/video-cutscene-hide
Hide a video cutscene after playing it
This commit is contained in:
commit
3c9f63892b
1 changed files with 76 additions and 0 deletions
|
@ -5,6 +5,7 @@ import flixel.FlxSprite;
|
|||
import flixel.tweens.FlxEase;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.util.FlxSignal;
|
||||
import flixel.util.FlxTimer;
|
||||
#if html5
|
||||
import funkin.graphics.video.FlxVideo;
|
||||
|
@ -28,6 +29,31 @@ class VideoCutscene
|
|||
static var vid:FlxVideoSprite;
|
||||
#end
|
||||
|
||||
/**
|
||||
* Called when the video is started.
|
||||
*/
|
||||
public static final onVideoStarted:FlxSignal = new FlxSignal();
|
||||
|
||||
/**
|
||||
* Called if the video is paused.
|
||||
*/
|
||||
public static final onVideoPaused:FlxSignal = new FlxSignal();
|
||||
|
||||
/**
|
||||
* Called if the video is resumed.
|
||||
*/
|
||||
public static final onVideoResumed:FlxSignal = new FlxSignal();
|
||||
|
||||
/**
|
||||
* Called if the video is restarted. onVideoStarted is not called.
|
||||
*/
|
||||
public static final onVideoRestarted:FlxSignal = new FlxSignal();
|
||||
|
||||
/**
|
||||
* Called when the video is ended or skipped.
|
||||
*/
|
||||
public static final onVideoEnded:FlxSignal = new FlxSignal();
|
||||
|
||||
/**
|
||||
* Play a video cutscene.
|
||||
* TODO: Currently this is hardcoded to start the countdown after the video is done.
|
||||
|
@ -94,6 +120,8 @@ class VideoCutscene
|
|||
PlayState.instance.add(vid);
|
||||
|
||||
PlayState.instance.refresh();
|
||||
|
||||
onVideoStarted.dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -129,6 +157,8 @@ class VideoCutscene
|
|||
vid.y = 0;
|
||||
// vid.scale.set(0.5, 0.5);
|
||||
});
|
||||
|
||||
onVideoStarted.dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -143,6 +173,7 @@ class VideoCutscene
|
|||
if (vid != null)
|
||||
{
|
||||
vid.restartVideo();
|
||||
onVideoRestarted.dispatch();
|
||||
}
|
||||
#end
|
||||
|
||||
|
@ -156,6 +187,8 @@ class VideoCutscene
|
|||
// Resume the video if it was paused.
|
||||
vid.resume();
|
||||
}
|
||||
|
||||
onVideoRestarted.dispatch();
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
@ -166,6 +199,7 @@ class VideoCutscene
|
|||
if (vid != null)
|
||||
{
|
||||
vid.pauseVideo();
|
||||
onVideoPaused.dispatch();
|
||||
}
|
||||
#end
|
||||
|
||||
|
@ -173,6 +207,45 @@ class VideoCutscene
|
|||
if (vid != null)
|
||||
{
|
||||
vid.pause();
|
||||
onVideoPaused.dispatch();
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
public static function hideVideo():Void
|
||||
{
|
||||
#if html5
|
||||
if (vid != null)
|
||||
{
|
||||
vid.visible = false;
|
||||
blackScreen.visible = false;
|
||||
}
|
||||
#end
|
||||
|
||||
#if hxCodec
|
||||
if (vid != null)
|
||||
{
|
||||
vid.visible = false;
|
||||
blackScreen.visible = false;
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
public static function showVideo():Void
|
||||
{
|
||||
#if html5
|
||||
if (vid != null)
|
||||
{
|
||||
vid.visible = true;
|
||||
blackScreen.visible = false;
|
||||
}
|
||||
#end
|
||||
|
||||
#if hxCodec
|
||||
if (vid != null)
|
||||
{
|
||||
vid.visible = true;
|
||||
blackScreen.visible = false;
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
@ -183,6 +256,7 @@ class VideoCutscene
|
|||
if (vid != null)
|
||||
{
|
||||
vid.resumeVideo();
|
||||
onVideoResumed.dispatch();
|
||||
}
|
||||
#end
|
||||
|
||||
|
@ -190,6 +264,7 @@ class VideoCutscene
|
|||
if (vid != null)
|
||||
{
|
||||
vid.resume();
|
||||
onVideoResumed.dispatch();
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
@ -240,6 +315,7 @@ class VideoCutscene
|
|||
{
|
||||
ease: FlxEase.quadInOut,
|
||||
onComplete: function(twn:FlxTween) {
|
||||
onVideoEnded.dispatch();
|
||||
onCutsceneFinish(cutsceneType);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue