Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Conflict With Modded StrumlineNote Sprite Looping Animation #3577

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/funkin/graphics/FunkinSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ class FunkinSprite extends FlxSprite
return true;
}

/**
* @param id The animation ID to check.
* @return Whether the animation is dynamic (has multiple frames). `false` for static, one-frame animations.
*/
public function isAnimationDynamic(id:String):Bool
{
if (this.animation == null) return false;
var animData = this.animation.getByName(id);
if (animData == null) return false;
return animData.numFrames > 1;
}

/**
* Acts similarly to `makeGraphic`, but with improved memory usage,
* at the expense of not being able to paint onto the resulting sprite.
Expand Down
41 changes: 31 additions & 10 deletions source/funkin/play/notes/StrumlineNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,46 @@ package funkin.play.notes;

import funkin.play.notes.notestyle.NoteStyle;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.FlxSprite;
import funkin.graphics.FunkinSprite;
import funkin.play.notes.NoteSprite;

/**
* The actual receptor that you see on screen.
*/
class StrumlineNote extends FlxSprite
class StrumlineNote extends FunkinSprite
{
/**
* Whether this strumline note is on the player's side or the opponent's side.
*/
public var isPlayer(default, null):Bool;

/**
* The direction which this strumline note is facing.
*/
public var direction(default, set):NoteDirection;

var confirmHoldTimer:Float = -1;

static final CONFIRM_HOLD_TIME:Float = 0.1;

function set_direction(value:NoteDirection):NoteDirection
{
this.direction = value;
return this.direction;
}

/**
* Set this flag to `true` to disable performance optimizations that cause
* the Strumline note sprite to ignore `velocity` and `acceleration`.
*/
public var forceActive:Bool = false;

/**
* How long to continue the hold note animation after a note is pressed.
*/
static final CONFIRM_HOLD_TIME:Float = 0.1;

/**
* How long the hold note animation has been playing after a note is pressed.
*/
var confirmHoldTimer:Float = -1;

public function new(noteStyle:NoteStyle, isPlayer:Bool, direction:NoteDirection)
{
super(0, 0);
Expand All @@ -41,7 +59,10 @@ class StrumlineNote extends FlxSprite
this.active = true;
}

function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int):Void {}
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int):Void
{
// Do nothing.
}

function onAnimationFinished(name:String):Void
{
Expand Down Expand Up @@ -103,19 +124,19 @@ class StrumlineNote extends FlxSprite

public function playStatic():Void
{
this.active = false;
this.active = (forceActive || isAnimationDynamic('static'));
this.playAnimation('static', true);
}

public function playPress():Void
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('press'));
this.playAnimation('press', true);
}

public function playConfirm():Void
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('confirm'));
this.playAnimation('confirm', true);
}

Expand Down
Loading