mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-21 14:23:00 +00:00
Add some cutom logic to determine if this.active is needed.
This commit is contained in:
parent
3aa4591bab
commit
de5cca1120
|
@ -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.
|
||||
|
|
|
@ -24,6 +24,12 @@ class StrumlineNote extends FlxSprite
|
|||
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;
|
||||
|
||||
public function new(noteStyle:NoteStyle, isPlayer:Bool, direction:NoteDirection)
|
||||
{
|
||||
super(0, 0);
|
||||
|
@ -103,19 +109,19 @@ class StrumlineNote extends FlxSprite
|
|||
|
||||
public function playStatic():Void
|
||||
{
|
||||
this.active = true;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue