mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-27 01:55:52 -05:00
Scrapped the weird FlxAltasSprite stuff and just used a tween. Also fixed some bugs with story menu
This commit is contained in:
parent
3975d34b70
commit
1f81e92827
5 changed files with 73 additions and 56 deletions
|
@ -3,6 +3,7 @@ package funkin.graphics;
|
|||
import flixel.FlxSprite;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import flixel.tweens.FlxTween;
|
||||
|
||||
/**
|
||||
* An FlxSprite with additional functionality.
|
||||
|
@ -217,7 +218,7 @@ class FunkinSprite extends FlxSprite
|
|||
}
|
||||
|
||||
/**
|
||||
* Ensure scale is applied when cloning a sprite.
|
||||
* Ensure scale is applied when cloning a sprite.R
|
||||
* The default `clone()` method acts kinda weird TBH.
|
||||
* @return A clone of this sprite.
|
||||
*/
|
||||
|
@ -230,4 +231,13 @@ class FunkinSprite extends FlxSprite
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override function destroy():Void
|
||||
{
|
||||
frames = null;
|
||||
// Cancel all tweens so they don't continue to run on a destroyed sprite.
|
||||
// This prevents crashes.
|
||||
FlxTween.cancelTweensOf(this);
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ class FlxAtlasSprite extends FlxAnimate
|
|||
ShowPivot: #if debug false #else false #end,
|
||||
Antialiasing: true,
|
||||
ScrollFactor: null,
|
||||
OverrideGraphics: [],
|
||||
// Offset: new FlxPoint(0, 0), // This is just FlxSprite.offset
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package funkin.ui.freeplay;
|
||||
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import flixel.util.FlxSort;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.util.FlxTimer;
|
||||
import flixel.tweens.FlxEase;
|
||||
import funkin.data.freeplay.AlbumRegistry;
|
||||
import funkin.graphics.adobeanimate.FlxAtlasSprite;
|
||||
import funkin.graphics.FunkinSprite;
|
||||
import funkin.util.SortUtil;
|
||||
import openfl.utils.Assets;
|
||||
|
||||
/**
|
||||
* The graphic for the album roll in the FreeplayState.
|
||||
|
@ -31,10 +34,12 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
return value;
|
||||
}
|
||||
|
||||
var albumArt:FlxAtlasSprite;
|
||||
var albumArt:FunkinSprite;
|
||||
var albumTitle:FunkinSprite;
|
||||
var difficultyStars:DifficultyStars;
|
||||
|
||||
var _exitMovers:Null<FreeplayState.ExitMoverData>;
|
||||
|
||||
var albumData:Album;
|
||||
|
||||
public function new()
|
||||
|
@ -42,7 +47,7 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
super();
|
||||
|
||||
albumTitle = new FunkinSprite(947, 491);
|
||||
albumTitle.visible = false;
|
||||
albumTitle.visible = true;
|
||||
albumTitle.zIndex = 200;
|
||||
add(albumTitle);
|
||||
|
||||
|
@ -69,28 +74,32 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
return;
|
||||
};
|
||||
|
||||
var albumArtGraphics:Array<FlxGraphic> = [null, albumData.getAlbumArtGraphic()];
|
||||
|
||||
if (albumArt != null)
|
||||
{
|
||||
FlxTween.cancelTweensOf(albumArt);
|
||||
albumArt.visible = false;
|
||||
albumArt.anim.stop();
|
||||
albumArt.destroy();
|
||||
remove(albumArt);
|
||||
}
|
||||
|
||||
// I wasn't able to get replacing to work properly on an existing object,
|
||||
// so I just throw the old one in the trash and make a new one.
|
||||
albumArt = new FlxAtlasSprite(640, 360, Paths.animateAtlas('freeplay/albumRoll'),
|
||||
{
|
||||
OverrideGraphics: albumArtGraphics,
|
||||
});
|
||||
// Paths.animateAtlas('freeplay/albumRoll'),
|
||||
albumArt = FunkinSprite.create(1500, 360, albumData.getAlbumArtAssetKey());
|
||||
albumArt.setGraphicSize(262, 262); // Magic number for size IG
|
||||
albumArt.zIndex = 100;
|
||||
|
||||
playIntro();
|
||||
add(albumArt);
|
||||
|
||||
albumTitle.loadGraphic(Paths.image(albumData.getAlbumTitleAssetKey()));
|
||||
applyExitMovers();
|
||||
|
||||
if (Assets.exists(Paths.image(albumData.getAlbumTitleAssetKey())))
|
||||
{
|
||||
albumTitle.loadGraphic(Paths.image(albumData.getAlbumTitleAssetKey()));
|
||||
}
|
||||
else
|
||||
{
|
||||
albumTitle.visible = false;
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
@ -104,8 +113,19 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
* Apply exit movers for the album roll.
|
||||
* @param exitMovers The exit movers to apply.
|
||||
*/
|
||||
public function applyExitMovers(exitMovers:FreeplayState.ExitMoverData):Void
|
||||
public function applyExitMovers(?exitMovers:FreeplayState.ExitMoverData):Void
|
||||
{
|
||||
if (exitMovers == null)
|
||||
{
|
||||
exitMovers = _exitMovers;
|
||||
}
|
||||
else
|
||||
{
|
||||
_exitMovers = exitMovers;
|
||||
}
|
||||
|
||||
if (exitMovers == null) return;
|
||||
|
||||
exitMovers.set([albumArt],
|
||||
{
|
||||
x: FlxG.width,
|
||||
|
@ -141,10 +161,12 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
public function playIntro():Void
|
||||
{
|
||||
albumArt.visible = true;
|
||||
albumArt.anim.play('');
|
||||
albumArt.anim.onComplete = function() {
|
||||
albumArt.anim.pause();
|
||||
};
|
||||
FlxTween.tween(albumArt, {x: 950, y: 320, angle: -340}, 0.5, {ease: FlxEase.quintOut});
|
||||
|
||||
albumTitle.visible = false;
|
||||
new FlxTimer().start(0.75, function(_) {
|
||||
showTitle();
|
||||
});
|
||||
}
|
||||
|
||||
public function setDifficultyStars(?difficulty:Int):Void
|
||||
|
@ -154,9 +176,6 @@ class AlbumRoll extends FlxSpriteGroup
|
|||
difficultyStars.difficulty = difficulty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the album title graphic visible.
|
||||
*/
|
||||
public function showTitle():Void
|
||||
{
|
||||
albumTitle.visible = true;
|
||||
|
|
|
@ -465,7 +465,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
|
||||
albumRoll.playIntro();
|
||||
|
||||
new FlxTimer().start(1, function(_) {
|
||||
new FlxTimer().start(0.75, function(_) {
|
||||
albumRoll.showTitle();
|
||||
});
|
||||
|
||||
|
@ -861,16 +861,6 @@ class FreeplayState extends MusicBeatSubState
|
|||
changeDiff(1);
|
||||
}
|
||||
|
||||
// TODO: DEBUG REMOVE THIS
|
||||
if (FlxG.keys.justPressed.P)
|
||||
{
|
||||
var newParams:FreeplayStateParams =
|
||||
{
|
||||
character: currentCharacter == 'bf' ? 'pico' : 'bf',
|
||||
};
|
||||
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.freeplay.FreeplayState(newParams, sticker)));
|
||||
}
|
||||
|
||||
if (controls.BACK && !typing.hasFocus)
|
||||
{
|
||||
FlxTween.globalManager.clear();
|
||||
|
|
|
@ -1,37 +1,33 @@
|
|||
package funkin.ui.story;
|
||||
|
||||
import funkin.ui.mainmenu.MainMenuState;
|
||||
import funkin.save.Save;
|
||||
import funkin.save.Save.SaveScoreData;
|
||||
import openfl.utils.Assets;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.tweens.FlxEase;
|
||||
import funkin.graphics.FunkinSprite;
|
||||
import funkin.ui.MusicBeatState;
|
||||
import flixel.tweens.FlxTween;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.util.FlxTimer;
|
||||
import funkin.data.level.LevelRegistry;
|
||||
import funkin.audio.FunkinSound;
|
||||
import funkin.data.level.LevelRegistry;
|
||||
import funkin.data.song.SongRegistry;
|
||||
import funkin.graphics.FunkinSprite;
|
||||
import funkin.modding.events.ScriptEvent;
|
||||
import funkin.modding.events.ScriptEventDispatcher;
|
||||
import funkin.play.PlayState;
|
||||
import funkin.play.PlayStatePlaylist;
|
||||
import funkin.ui.mainmenu.MainMenuState;
|
||||
import funkin.play.song.Song;
|
||||
import funkin.data.song.SongData.SongMusicData;
|
||||
import funkin.data.song.SongRegistry;
|
||||
import funkin.util.MathUtil;
|
||||
import funkin.save.Save;
|
||||
import funkin.save.Save.SaveScoreData;
|
||||
import funkin.ui.mainmenu.MainMenuState;
|
||||
import funkin.ui.MusicBeatState;
|
||||
import funkin.ui.transition.LoadingState;
|
||||
import funkin.ui.transition.StickerSubState;
|
||||
import funkin.util.MathUtil;
|
||||
import openfl.utils.Assets;
|
||||
|
||||
class StoryMenuState extends MusicBeatState
|
||||
{
|
||||
static final DEFAULT_BACKGROUND_COLOR:FlxColor = FlxColor.fromString("#F9CF51");
|
||||
static final DEFAULT_BACKGROUND_COLOR:FlxColor = FlxColor.fromString('#F9CF51');
|
||||
static final BACKGROUND_HEIGHT:Int = 400;
|
||||
|
||||
var currentDifficultyId:String = 'normal';
|
||||
|
@ -166,25 +162,25 @@ class StoryMenuState extends MusicBeatState
|
|||
updateProps();
|
||||
|
||||
tracklistText = new FlxText(FlxG.width * 0.05, levelBackground.x + levelBackground.height + 100, 0, "Tracks", 32);
|
||||
tracklistText.setFormat("VCR OSD Mono", 32);
|
||||
tracklistText.setFormat('VCR OSD Mono', 32);
|
||||
tracklistText.alignment = CENTER;
|
||||
tracklistText.color = 0xFFe55777;
|
||||
tracklistText.color = 0xFFE55777;
|
||||
add(tracklistText);
|
||||
|
||||
scoreText = new FlxText(10, 10, 0, 'HIGH SCORE: 42069420');
|
||||
scoreText.setFormat("VCR OSD Mono", 32);
|
||||
scoreText.setFormat('VCR OSD Mono', 32);
|
||||
scoreText.zIndex = 1000;
|
||||
add(scoreText);
|
||||
|
||||
modeText = new FlxText(10, 10, 0, 'Base Game Levels [TAB to switch]');
|
||||
modeText.setFormat("VCR OSD Mono", 32);
|
||||
modeText.setFormat('VCR OSD Mono', 32);
|
||||
modeText.screenCenter(X);
|
||||
modeText.visible = hasModdedLevels();
|
||||
modeText.zIndex = 1000;
|
||||
add(modeText);
|
||||
|
||||
levelTitleText = new FlxText(FlxG.width * 0.7, 10, 0, 'LEVEL 1');
|
||||
levelTitleText.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, RIGHT);
|
||||
levelTitleText.setFormat('VCR OSD Mono', 32, FlxColor.WHITE, RIGHT);
|
||||
levelTitleText.alpha = 0.7;
|
||||
levelTitleText.zIndex = 1000;
|
||||
add(levelTitleText);
|
||||
|
@ -217,7 +213,7 @@ class StoryMenuState extends MusicBeatState
|
|||
|
||||
#if discord_rpc
|
||||
// Updating Discord Rich Presence
|
||||
DiscordClient.changePresence("In the Menus", null);
|
||||
DiscordClient.changePresence('In the Menus', null);
|
||||
#end
|
||||
}
|
||||
|
||||
|
@ -307,7 +303,7 @@ class StoryMenuState extends MusicBeatState
|
|||
changeDifficulty(0);
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
override function update(elapsed:Float):Void
|
||||
{
|
||||
Conductor.instance.update();
|
||||
|
||||
|
@ -552,10 +548,13 @@ class StoryMenuState extends MusicBeatState
|
|||
FlxTransitionableState.skipNextTransIn = false;
|
||||
FlxTransitionableState.skipNextTransOut = false;
|
||||
|
||||
var targetVariation:String = targetSong.getFirstValidVariation(PlayStatePlaylist.campaignDifficulty);
|
||||
|
||||
LoadingState.loadPlayState(
|
||||
{
|
||||
targetSong: targetSong,
|
||||
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
||||
targetVariation: targetVariation
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue