Skip to content

Commit

Permalink
Now you can replace spritesheets
Browse files Browse the repository at this point in the history
you can replace any spritesheet
  • Loading branch information
CamLikesKirby committed Jun 15, 2024
1 parent 418b9a4 commit 6ef855c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 1 addition & 7 deletions source/BGSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ class BGSprite extends FlxSprite
{
if (hasAnimations)
{
var theActualPath:String = '';
if (FileSystem.exists(TitleState.modFolder + '/' + customPath)) {
theActualPath = customPath;
} else {
theActualPath = path;
}
frames = Paths.getSparrowAtlas(theActualPath);
frames = Paths.getSparrowAtlas(path);
for (i in 0...animations.length)
{
var curAnim = animations[i];
Expand Down
10 changes: 9 additions & 1 deletion source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,15 @@ class Paths

inline static public function getSparrowAtlas(key:String, ?library:String)
{
var what = library == null ? 'assets' : 'assets/' + library;
var short = what + '/images/' + key;
//trace(TitleState.modFolder + '/' + short + '.png');
if (FileSystem.exists(TitleState.modFolder + '/' + short + '.png') && FileSystem.exists(TitleState.modFolder + '/' + short + '.xml')) {
trace('custom exists');
return FlxAtlasFrames.fromSparrow(customImage(TitleState.modFolder + '/' + short), customFile(TitleState.modFolder + '/' + short + '.xml'));
} else {
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
}
}

inline static public function getCustomSparrowAtlas(key:String)
Expand All @@ -338,7 +346,7 @@ class Paths

inline static public function getPackerAtlas(key:String, ?library:String)
{
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));
}

inline static public function getCustomPackerAtlas(key:String)
Expand Down

0 comments on commit 6ef855c

Please sign in to comment.