@@ -46,7 +46,7 @@ class HealthIcon extends FlxSprite
4646 if (! Paths .fileExists (' images/' + name + ' .png' , IMAGE )) name = ' icons/icon-face' ; // Prevents crash from missing icon
4747 var file : Dynamic = Paths .image (name );
4848
49- var jsonPath : String = name ;
49+ var jsonPath : String = haxe.io. Path . directory ( Paths . file ( ' images/icons/icons/ ' )) ;
5050 var jsonData : Dynamic = null ;
5151
5252 // Try to load JSON file
@@ -74,7 +74,7 @@ class HealthIcon extends FlxSprite
7474 loadGraphic (file ); // Load to guess size
7575 type = (width < 200 ? SINGLE : ((width > 199 && width < 301 ) ? DEFAULT : WINNING ));
7676
77- trace (' No JSON file found, guessing type based on size: ' + type + ' (' + width + ' px)' );
77+ // trace('No JSON file found, guessing type based on size: ' + type + ' (' + width + 'px)');
7878
7979 // Create or update JSON file with guessed type
8080 jsonData = { type : switch (type ) {
@@ -83,11 +83,13 @@ class HealthIcon extends FlxSprite
8383 case WINNING : ' WINNING' ;
8484 }};
8585 if (! sys. FileSystem .exists (jsonPath )) {
86- var file = sys.io. File .write (jsonPath , true ); // ???
87- file .close ();
86+ try {
87+ var file = sys.io. File .write (jsonPath , true ); // ???
88+ file .close ();
89+ } catch (e ) {trace (" Failed to write JSON for " + char );}
8890 }
8991 sys.io. File .saveContent (jsonPath , haxe. Json .stringify (jsonData , null , ' \t ' ));
90- trace (' Remembering this type for future use: ' + jsonPath );
92+ // trace('Remembering this type for future use: ' + jsonPath);
9193 }
9294
9395 loadGraphic (file , true , Math .floor (width / (type + 1 )), Math .floor (height ));
0 commit comments