easier storymode menu adding onto

This commit is contained in:
Cameron Taylor 2021-03-01 22:35:27 -05:00
parent 0d3e116d88
commit a6a3db6aa4
10 changed files with 26 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,41 +1,49 @@
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
import flixel.util.FlxColor;
class MenuItem extends FlxSpriteGroup
{
public var targetY:Float = 0;
public var week:FlxSprite;
public var flashingInt:Int = 0;
public function new(x:Float, y:Float, weekNum:Int = 0)
{
super(x, y);
var tex = Paths.getSparrowAtlas('campaign_menu_UI_assets');
week = new FlxSprite();
week.frames = tex;
// TUTORIAL IS WEEK 0
week.animation.addByPrefix('week0', 'tutorial selected', 24);
week.animation.addByPrefix('week1', "WEEK1 select", 24);
week.animation.addByPrefix('week2', "week2 select", 24);
week.animation.addByPrefix('week3', "Week 3 press", 24);
week.animation.addByPrefix('week4', "Week 4 press", 24);
week.animation.addByPrefix('week5', "week 5", 24);
week.animation.addByPrefix('week6', "Week 6", 24);
week = new FlxSprite().loadGraphic(Paths.image('storymenu/week' + weekNum));
add(week);
week.animation.play('week' + weekNum);
week.animation.pause();
week.updateHitbox();
}
private var isFlashing:Bool = false;
public function startFlashing():Void
{
isFlashing = true;
}
// if it runs at 60fps, fake framerate will be 6
// if it runs at 144 fps, fake framerate will be like 14, and will update the graphic every 0.016666 * 3 seconds still???
// so it runs basically every so many seconds, not dependant on framerate??
// I'm still learning how math works thanks whoever is reading this lol
var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10);
override function update(elapsed:Float)
{
super.update(elapsed);
y = FlxMath.lerp(y, (targetY * 120) + 480, 0.17);
if (isFlashing)
flashingInt += 1;
if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2))
week.color = 0xFF33ffff;
else
week.color = FlxColor.WHITE;
}
}

View File

@ -291,7 +291,7 @@ class StoryMenuState extends MusicBeatState
{
FlxG.sound.play(Paths.sound('confirmMenu'));
grpWeekText.members[curWeek].week.animation.resume();
grpWeekText.members[curWeek].startFlashing();
grpWeekCharacters.members[1].animation.play('bfConfirm');
stopspamming = true;
}