mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
Fix for switching to old icon on isPixel levels
This commit is contained in:
parent
960c151985
commit
62d0b33689
|
@ -150,13 +150,17 @@ class HealthIcon extends FunkinSprite
|
||||||
{
|
{
|
||||||
if (characterId == 'bf-old')
|
if (characterId == 'bf-old')
|
||||||
{
|
{
|
||||||
|
isPixel = PlayState.instance.currentStage.getBoyfriend().isPixel;
|
||||||
PlayState.instance.currentStage.getBoyfriend().initHealthIcon(false);
|
PlayState.instance.currentStage.getBoyfriend().initHealthIcon(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
characterId = 'bf-old';
|
characterId = 'bf-old';
|
||||||
|
isPixel = false;
|
||||||
loadCharacter(characterId);
|
loadCharacter(characterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lerpIconSize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -199,6 +203,22 @@ class HealthIcon extends FunkinSprite
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
if (bopEvery != 0)
|
if (bopEvery != 0)
|
||||||
|
{
|
||||||
|
lerpIconSize();
|
||||||
|
|
||||||
|
// Lerp the health icon back to its normal angle.
|
||||||
|
this.angle = MathUtil.coolLerp(this.angle, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the calculation to lerp the icon size. Usually called every frame, but can be forced to the target size.
|
||||||
|
* Mainly forced when changing to old icon to not have a weird lerp related to changing from pixel icon to non-pixel old icon
|
||||||
|
* @param force Force the icon immedialtely to be the target size. Defaults to false.
|
||||||
|
*/
|
||||||
|
function lerpIconSize(force:Bool = false):Void
|
||||||
{
|
{
|
||||||
// Lerp the health icon back to its normal size,
|
// Lerp the health icon back to its normal size,
|
||||||
// while maintaining aspect ratio.
|
// while maintaining aspect ratio.
|
||||||
|
@ -207,24 +227,22 @@ class HealthIcon extends FunkinSprite
|
||||||
// Apply linear interpolation while accounting for frame rate.
|
// Apply linear interpolation while accounting for frame rate.
|
||||||
var targetSize:Int = Std.int(MathUtil.coolLerp(this.width, HEALTH_ICON_SIZE * this.size.x, 0.15));
|
var targetSize:Int = Std.int(MathUtil.coolLerp(this.width, HEALTH_ICON_SIZE * this.size.x, 0.15));
|
||||||
|
|
||||||
|
if (force) targetSize = Std.int(HEALTH_ICON_SIZE * this.size.x);
|
||||||
|
|
||||||
setGraphicSize(targetSize, 0);
|
setGraphicSize(targetSize, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var targetSize:Int = Std.int(MathUtil.coolLerp(this.height, HEALTH_ICON_SIZE * this.size.y, 0.15));
|
var targetSize:Int = Std.int(MathUtil.coolLerp(this.height, HEALTH_ICON_SIZE * this.size.y, 0.15));
|
||||||
|
|
||||||
|
if (force) targetSize = Std.int(HEALTH_ICON_SIZE * this.size.y);
|
||||||
|
|
||||||
setGraphicSize(0, targetSize);
|
setGraphicSize(0, targetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lerp the health icon back to its normal angle.
|
|
||||||
this.angle = MathUtil.coolLerp(this.angle, 0, 0.15);
|
|
||||||
|
|
||||||
this.updateHitbox();
|
this.updateHitbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updatePosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the position (and status) of the health icon.
|
* Update the position (and status) of the health icon.
|
||||||
*/
|
*/
|
||||||
|
@ -412,6 +430,8 @@ class HealthIcon extends FunkinSprite
|
||||||
|
|
||||||
isLegacyStyle = !isNewSpritesheet(charId);
|
isLegacyStyle = !isNewSpritesheet(charId);
|
||||||
|
|
||||||
|
trace(' Loading health icon for character: $charId (legacy: $isLegacyStyle)');
|
||||||
|
|
||||||
if (!isLegacyStyle)
|
if (!isLegacyStyle)
|
||||||
{
|
{
|
||||||
loadSparrow('icons/icon-$charId');
|
loadSparrow('icons/icon-$charId');
|
||||||
|
|
Loading…
Reference in a new issue