mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
Fix default health icon not used
This commit is contained in:
parent
27bf88c11e
commit
2fb55ba3ed
|
@ -33,7 +33,7 @@ class HealthIcon extends FunkinSprite
|
||||||
* The character this icon is representing.
|
* The character this icon is representing.
|
||||||
* Setting this variable will automatically update the graphic.
|
* Setting this variable will automatically update the graphic.
|
||||||
*/
|
*/
|
||||||
public var characterId(default, set):Null<String>;
|
public var characterId(default, set):String = Constants.DEFAULT_HEALTH_ICON;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this health icon should automatically update its state based on the character's health.
|
* Whether this health icon should automatically update its state based on the character's health.
|
||||||
|
@ -116,7 +116,7 @@ class HealthIcon extends FunkinSprite
|
||||||
*/
|
*/
|
||||||
static final POSITION_OFFSET:Int = 26;
|
static final POSITION_OFFSET:Int = 26;
|
||||||
|
|
||||||
public function new(char:String = 'bf', playerId:Int = 0)
|
public function new(char:Null<String>, playerId:Int = 0)
|
||||||
{
|
{
|
||||||
super(0, 0);
|
super(0, 0);
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
|
@ -127,7 +127,7 @@ class HealthIcon extends FunkinSprite
|
||||||
initTargetSize();
|
initTargetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_characterId(value:Null<String>):Null<String>
|
function set_characterId(value:Null<String>):String
|
||||||
{
|
{
|
||||||
if (value == characterId) return value;
|
if (value == characterId) return value;
|
||||||
|
|
||||||
|
@ -380,20 +380,9 @@ class HealthIcon extends FunkinSprite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function correctCharacterId(charId:Null<String>):String
|
function iconExists(charId:String):Bool
|
||||||
{
|
{
|
||||||
if (charId == null)
|
return Assets.exists(Paths.image('icons/icon-$charId'));
|
||||||
{
|
|
||||||
return Constants.DEFAULT_HEALTH_ICON;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Assets.exists(Paths.image('icons/icon-$charId')))
|
|
||||||
{
|
|
||||||
FlxG.log.warn('No icon for character: $charId : using default placeholder face instead!');
|
|
||||||
return Constants.DEFAULT_HEALTH_ICON;
|
|
||||||
}
|
|
||||||
|
|
||||||
return charId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNewSpritesheet(charId:String):Bool
|
function isNewSpritesheet(charId:String):Bool
|
||||||
|
@ -403,11 +392,11 @@ class HealthIcon extends FunkinSprite
|
||||||
|
|
||||||
function loadCharacter(charId:Null<String>):Void
|
function loadCharacter(charId:Null<String>):Void
|
||||||
{
|
{
|
||||||
if (charId == null || correctCharacterId(charId) != charId)
|
if (charId == null || !iconExists(charId))
|
||||||
{
|
{
|
||||||
// This will recursively trigger loadCharacter to be called again.
|
FlxG.log.warn('No icon for character: $charId : using default placeholder face instead!');
|
||||||
characterId = correctCharacterId(charId);
|
characterId = Constants.DEFAULT_HEALTH_ICON;
|
||||||
return;
|
charId = characterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
isLegacyStyle = !isNewSpritesheet(charId);
|
isLegacyStyle = !isNewSpritesheet(charId);
|
||||||
|
|
Loading…
Reference in a new issue