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

cool menu movement

This commit is contained in:
Cameron Taylor 2020-10-30 14:55:20 -07:00
parent 9b53f111a2
commit c11564e065
2 changed files with 32 additions and 5 deletions

View file

@ -3,10 +3,13 @@ package;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup; import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
class MenuItem extends FlxSpriteGroup class MenuItem extends FlxSpriteGroup
{ {
public function new(x:Float, y:Float, week:Int = 0, unlocked:Bool = false) public var targetY:Float = 0;
public function new(x:Float, y:Float, weekNum:Int = 0, unlocked:Bool = false)
{ {
super(x, y); super(x, y);
@ -18,7 +21,7 @@ class MenuItem extends FlxSpriteGroup
week.animation.addByPrefix('week1', "week2 select", 24); week.animation.addByPrefix('week1', "week2 select", 24);
add(week); add(week);
week.animation.play('week' + week); week.animation.play('week' + weekNum);
week.updateHitbox(); week.updateHitbox();
if (!unlocked) if (!unlocked)
@ -29,7 +32,13 @@ class MenuItem extends FlxSpriteGroup
lock.frames = tex; lock.frames = tex;
lock.animation.addByPrefix('lock', 'lock'); lock.animation.addByPrefix('lock', 'lock');
lock.animation.play('lock'); lock.animation.play('lock');
add(lock); // add(lock);
} }
} }
override function update(elapsed:Float)
{
super.update(elapsed);
y = FlxMath.lerp(y, (targetY * 120) + 480, 0.17);
}
} }

View file

@ -3,6 +3,7 @@ package;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText; import flixel.text.FlxText;
using StringTools; using StringTools;
@ -17,6 +18,8 @@ class StoryMenuState extends MusicBeatState
var txtTracklist:FlxText; var txtTracklist:FlxText;
var grpWeekText:FlxTypedGroup<MenuItem>;
override function create() override function create()
{ {
scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36); scoreText = new FlxText(10, 10, 0, "SCORE: 49324858", 36);
@ -33,6 +36,9 @@ class StoryMenuState extends MusicBeatState
var ui_tex = FlxAtlasFrames.fromSparrow(AssetPaths.campaign_menu_UI_assets__png, AssetPaths.campaign_menu_UI_assets__xml); var ui_tex = FlxAtlasFrames.fromSparrow(AssetPaths.campaign_menu_UI_assets__png, AssetPaths.campaign_menu_UI_assets__xml);
var yellowBG:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 400, 0xFFF9CF51); var yellowBG:FlxSprite = new FlxSprite(0, 56).makeGraphic(FlxG.width, 400, 0xFFF9CF51);
grpWeekText = new FlxTypedGroup<MenuItem>();
add(grpWeekText);
for (i in 0...weekData.length) for (i in 0...weekData.length)
{ {
var unlocked:Bool = true; var unlocked:Bool = true;
@ -41,7 +47,11 @@ class StoryMenuState extends MusicBeatState
unlocked = false; unlocked = false;
var weekThing:MenuItem = new MenuItem(0, yellowBG.y + yellowBG.height + 10, i, unlocked); var weekThing:MenuItem = new MenuItem(0, yellowBG.y + yellowBG.height + 10, i, unlocked);
add(weekThing); weekThing.y += ((weekThing.height + 20) * i);
weekThing.targetY = i;
grpWeekText.add(weekThing);
weekThing.screenCenter(X);
} }
add(yellowBG); add(yellowBG);
@ -80,6 +90,14 @@ class StoryMenuState extends MusicBeatState
if (curWeek < 0) if (curWeek < 0)
curWeek = weekData.length - 1; curWeek = weekData.length - 1;
var bullShit:Int = 0;
for (item in grpWeekText.members)
{
item.targetY = bullShit - curWeek;
bullShit++;
}
updateText(); updateText();
} }
@ -94,7 +112,7 @@ class StoryMenuState extends MusicBeatState
txtTracklist.text += "\n" + i; txtTracklist.text += "\n" + i;
} }
txtTracklist.text.toUpperCase(); txtTracklist.text = txtTracklist.text.toUpperCase();
txtTracklist.screenCenter(X); txtTracklist.screenCenter(X);
txtTracklist.x -= FlxG.width * 0.35; txtTracklist.x -= FlxG.width * 0.35;