Work in progress on hold covers

This commit is contained in:
EliteMasterEric 2023-07-05 22:11:58 -04:00
parent b615fbf82a
commit 8e071221ff
6 changed files with 89 additions and 29 deletions

View file

@ -1660,6 +1660,11 @@ class PlayState extends MusicBeatState
// Command the opponent to hit the note on time.
// NOTE: This is what handles the strumline and cleaning up the note itself!
opponentStrumline.hitNote(note);
if (note.holdNoteSprite != null)
{
opponentStrumline.playNoteHoldCover(note.holdNoteSprite);
}
}
else if (Conductor.songPosition > hitWindowStart)
{
@ -1945,7 +1950,7 @@ class PlayState extends MusicBeatState
// Calling event.cancelEvent() skips all the other logic! Neat!
if (event.eventCanceled) return;
if (!note.isSustainNote)
if (!note.isHoldNote)
{
Highscore.tallies.combo++;
Highscore.tallies.totalNotesHit++;
@ -1957,6 +1962,11 @@ class PlayState extends MusicBeatState
playerStrumline.hitNote(note);
if (note.holdNoteSprite != null)
{
playerStrumline.playNoteHoldCover(note.holdNoteSprite);
}
vocals.playerVolume = 1;
}
}
@ -2190,11 +2200,6 @@ class PlayState extends MusicBeatState
playerStrumline.playNoteSplash(daNote.noteData.getDirection());
}
if (daNote.noteData.isHoldNote)
{
playerStrumline.playNoteHoldCover(daNote.noteData.getDirection());
}
// Only add the score if you're not on practice mode
if (!isPracticeMode)
{

View file

@ -13,14 +13,11 @@ class NoteHoldCover extends FlxTypedSpriteGroup<FlxSprite>
static var glowFrames:FlxAtlasFrames;
public var holdNote:SustainTrail;
var glow:FlxSprite;
var sparks:FlxSprite;
public static function preloadFrames():Void
{
glowFrames = Paths.getSparrowAtlas('holdCoverRed');
}
public function new()
{
super(0, 0);
@ -28,6 +25,12 @@ class NoteHoldCover extends FlxTypedSpriteGroup<FlxSprite>
setup();
}
public static function preloadFrames():Void
{
glowFrames = Paths.getSparrowAtlas('holdCoverRed');
glowFrames.parent.persist = true;
}
/**
* Add ALL the animations to this sprite. We will recycle and reuse the FlxSprite multiple times.
*/
@ -38,8 +41,9 @@ class NoteHoldCover extends FlxTypedSpriteGroup<FlxSprite>
if (glowFrames == null) preloadFrames();
glow.frames = glowFrames;
glow.animation.addByPrefix('holdCoverStartRed', 'holdCoverStartRed0', FRAMERATE_DEFAULT, false, false, false);
glow.animation.addByPrefix('holdCoverRed', 'holdCoverRed0', FRAMERATE_DEFAULT, true, false, false);
glow.animation.addByPrefix('holdCoverEndRed', 'holdCoverEndRed0', FRAMERATE_DEFAULT, true, false, false);
glow.animation.addByPrefix('holdCoverEndRed', 'holdCoverEndRed0', FRAMERATE_DEFAULT, false, false, false);
glow.animation.finishCallback = this.onAnimationFinished;
@ -49,26 +53,48 @@ class NoteHoldCover extends FlxTypedSpriteGroup<FlxSprite>
}
}
public function playStart(direction:NoteDirection):Void
public override function update(elapsed):Void
{
super.update(elapsed);
if (!holdNote.alive && !glow.animation.curAnim.name.startsWith('holdCoverEnd'))
{
this.visible = false;
this.kill();
}
else
{
this.visible = true;
}
}
public function playStart():Void
{
// glow.animation.play('holdCoverStart${noteDirection.colorName.toTitleCase()}');\
glow.animation.play('holdCoverStartRed');
}
public function playContinue():Void
{
// glow.animation.play('holdCover${noteDirection.colorName.toTitleCase()}');\
glow.animation.play('holdCoverRed');
}
public function playContinue(direction:NoteDirection):Void
{
glow.animation.play('holdCoverRed');
}
public function playEnd(direction:NoteDirection):Void
public function playEnd():Void
{
// glow.animation.play('holdCoverEnd${noteDirection.colorName.toTitleCase()}');\
glow.animation.play('holdCoverEndRed');
}
public function onAnimationFinished(animationName:String):Void
{
if (animationName.startsWith('holdCoverStart'))
{
playContinue();
}
if (animationName.startsWith('holdCoverEnd'))
{
// *lightning* *zap* *crackle*
this.visible = false;
this.kill();
}
}

View file

@ -61,7 +61,12 @@ class NoteSprite extends FlxSprite
public var noteData:SongNoteData;
public var isSustainNote:Bool = false;
public var isHoldNote(get, never):Bool;
function get_isHoldNote():Bool
{
return noteData.length > 0;
}
/**
* Set this flag to true when hitting the note to avoid scoring it multiple times.

View file

@ -264,6 +264,8 @@ class Strumline extends FlxSpriteGroup
// Hold note is offscreen, kill it.
holdNote.visible = false;
holdNote.kill(); // Do not destroy! Recycling is faster.
// The cover will see this and clean itself up.
}
else if (holdNote.hitNote && holdNote.sustainLength <= 0)
{
@ -276,6 +278,12 @@ class Strumline extends FlxSpriteGroup
{
playStatic(holdNote.noteDirection);
}
if (holdNote.cover != null)
{
holdNote.cover.playEnd();
}
holdNote.visible = false;
holdNote.kill();
}
@ -456,7 +464,7 @@ class Strumline extends FlxSpriteGroup
}
}
public function playNoteHoldCover(direction:NoteDirection):Void
public function playNoteHoldCover(holdNote:SustainTrail):Void
{
// TODO: Add a setting to disable note splashes.
// if (Settings.noSplash) return;
@ -465,15 +473,22 @@ class Strumline extends FlxSpriteGroup
if (cover != null)
{
cover.playStart(direction);
cover.holdNote = holdNote;
holdNote.cover = cover;
cover.visible = true;
cover.playStart();
cover.x = this.x;
cover.x += getXPos(direction);
cover.x -= cover.width / 8;
cover.x += INITIAL_OFFSET;
cover.x += getXPos(holdNote.noteDirection);
cover.x += STRUMLINE_SIZE / 2;
cover.x -= cover.width / 2;
// cover.x += INITIAL_OFFSET * 2;
cover.y = this.y;
cover.y -= cover.height / 4;
//
cover.y += INITIAL_OFFSET;
cover.y += STRUMLINE_SIZE / 2;
// cover.y -= cover.height / 2;
// cover.y += STRUMLINE_SIZE / 2;
}
}

View file

@ -32,6 +32,8 @@ class SustainTrail extends FlxSprite
public var fullSustainLength:Float = 0;
public var noteData:SongNoteData;
public var cover:NoteHoldCover = null;
/**
* Set to `true` if the user hit the note and is currently holding the sustain.
* Should display associated effects.

View file

@ -178,8 +178,15 @@ class AtlasChar extends FlxSprite
if (this.char != value)
{
var prefix = getAnimPrefix(value);
animation.addByPrefix("anim", prefix, 24);
animation.play("anim");
animation.addByPrefix('anim', prefix, 24);
if (animation.exists('anim'))
{
animation.play('anim');
}
else
{
trace('Could not find animation for char "' + value + '"');
}
updateHitbox();
}