easier storymode menu adding onto
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 6.8 KiB |
|
@ -1,41 +1,49 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
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;
|
import flixel.math.FlxMath;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
class MenuItem extends FlxSpriteGroup
|
class MenuItem extends FlxSpriteGroup
|
||||||
{
|
{
|
||||||
public var targetY:Float = 0;
|
public var targetY:Float = 0;
|
||||||
public var week:FlxSprite;
|
public var week:FlxSprite;
|
||||||
|
public var flashingInt:Int = 0;
|
||||||
|
|
||||||
public function new(x:Float, y:Float, weekNum:Int = 0)
|
public function new(x:Float, y:Float, weekNum:Int = 0)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
week = new FlxSprite().loadGraphic(Paths.image('storymenu/week' + weekNum));
|
||||||
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);
|
|
||||||
add(week);
|
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)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
y = FlxMath.lerp(y, (targetY * 120) + 480, 0.17);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ class StoryMenuState extends MusicBeatState
|
||||||
{
|
{
|
||||||
FlxG.sound.play(Paths.sound('confirmMenu'));
|
FlxG.sound.play(Paths.sound('confirmMenu'));
|
||||||
|
|
||||||
grpWeekText.members[curWeek].week.animation.resume();
|
grpWeekText.members[curWeek].startFlashing();
|
||||||
grpWeekCharacters.members[1].animation.play('bfConfirm');
|
grpWeekCharacters.members[1].animation.play('bfConfirm');
|
||||||
stopspamming = true;
|
stopspamming = true;
|
||||||
}
|
}
|
||||||
|
|