1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

readd IntroSubState from char unlock

This commit is contained in:
CheemsAndFriends 2024-09-11 20:49:55 +02:00
parent bea23c37a8
commit 9f5c154b1d

View file

@ -8,22 +8,24 @@ import hxcodec.flixel.FlxVideoSprite;
#end
import funkin.ui.MusicBeatSubState;
import funkin.audio.FunkinSound;
import funkin.save.Save;
/**
* After about 2 minutes of inactivity on the title screen,
* the game will enter the Attract state, as a reference to physical arcade machines.
*
* In the current version, this just plays the ~~Kickstarter trailer~~ Erect teaser, but this can be changed to
* gameplay footage, a generic game trailer, or something more elaborate.
* When you first enter the character select state, it will play an introductory video opening up the lights
*/
class IntroSubState extends MusicBeatSubState
{
static final ATTRACT_VIDEO_PATH:String = Paths.stripLibrary(Paths.videos('introSelect'));
static final LIGHTS_VIDEO_PATH:String = Paths.stripLibrary(Paths.videos('introSelect'));
var introSound:FunkinSound = null;
public override function create():Void
{
if (Save.instance.oldChar)
{
onLightsEnd();
return;
}
// Pause existing music.
if (FlxG.sound.music != null)
{
@ -32,15 +34,20 @@ class IntroSubState extends MusicBeatSubState
}
#if html5
trace('Playing web video ${ATTRACT_VIDEO_PATH}');
playVideoHTML5(ATTRACT_VIDEO_PATH);
trace('Playing web video ${LIGHTS_VIDEO_PATH}');
playVideoHTML5(LIGHTS_VIDEO_PATH);
#end
#if hxCodec
trace('Playing native video ${ATTRACT_VIDEO_PATH}');
playVideoNative(ATTRACT_VIDEO_PATH);
trace('Playing native video ${LIGHTS_VIDEO_PATH}');
playVideoNative(LIGHTS_VIDEO_PATH);
#end
// Im TOO lazy to even care, so uh, yep
FlxG.camera.zoom = 0.66666666666666666666666666666667;
vid.x = -(FlxG.width - (FlxG.width * FlxG.camera.zoom));
vid.y = -((FlxG.height - (FlxG.height * FlxG.camera.zoom)) * 0.75);
introSound = new FunkinSound();
introSound.loadEmbedded(Paths.sound('CS_Lights'));
introSound.pitch = 1;
@ -64,7 +71,7 @@ class IntroSubState extends MusicBeatSubState
{
vid.zIndex = 0;
vid.finishCallback = onAttractEnd;
vid.finishCallback = onLightsEnd;
add(vid);
}
@ -88,7 +95,7 @@ class IntroSubState extends MusicBeatSubState
if (vid != null)
{
vid.zIndex = 0;
vid.bitmap.onEndReached.add(onAttractEnd);
vid.bitmap.onEndReached.add(onLightsEnd);
add(vid);
vid.play(filePath, false);
@ -104,30 +111,33 @@ class IntroSubState extends MusicBeatSubState
{
super.update(elapsed);
if (controls.ACCEPT)
{
onAttractEnd();
}
// if (!introSound.paused)
// {
// #if html5
// @:privateAccess
// vid.netStream.seek(introSound.time);
// #elseif hxCodec
// vid.bitmap.time = Std.int(introSound.time);
// #end
// }
}
/**
* When the attraction state ends (after the video ends or the user presses any button),
* switch immediately to the title screen.
* When the lights video finishes, it will close the substate
*/
function onAttractEnd():Void
function onLightsEnd():Void
{
#if (html5 || hxCodec)
if (vid != null)
{
#if hxCodec
vid.stop();
#end
remove(vid);
vid.destroy();
vid = null;
}
#end
FlxG.camera.zoom = 1;
close();
}