diff --git a/packages/flame_texturepacker/README.md b/packages/flame_texturepacker/README.md index dcc0744f534..292d10fd0b9 100644 --- a/packages/flame_texturepacker/README.md +++ b/packages/flame_texturepacker/README.md @@ -56,7 +56,7 @@ Import the plugin like this: Load the TextureAtlas passing the path of the sprite sheet atlas file: ```Dart -final atlas = await fromAtlas('atlas_map.atlas'); +final atlas = await atlasFromAssets('atlas_map.atlas'); ``` @@ -66,7 +66,7 @@ If you are using file storage, grab your atlas file like this: ```Dart final documentsPath = (await getApplicationDocumentsDirectory()).path; -final atlas = await fromAtlas('$documentsPath/atlas_map.atlas', fromStorage: true); +final atlas = await atlasFromStorage('$documentsPath/atlas_map.atlas'); ``` Get a list of sprites ordered by their index, you can use the list to generate an animation: diff --git a/packages/flame_texturepacker/example/lib/main.dart b/packages/flame_texturepacker/example/lib/main.dart index 3fac2802ff0..24dce3f9c69 100644 --- a/packages/flame_texturepacker/example/lib/main.dart +++ b/packages/flame_texturepacker/example/lib/main.dart @@ -18,7 +18,7 @@ class MyGame extends FlameGame { super.onLoad(); // Load the atlasMap. - final atlas = await fromAtlas('atlas_map.atlas'); + final atlas = await atlasFromAssets('atlas_map.atlas'); // Get a list of sprites ordered by their index final walkingSprites = atlas.findSpritesByName('robot_walk'); diff --git a/packages/flame_texturepacker/lib/flame_texturepacker.dart b/packages/flame_texturepacker/lib/flame_texturepacker.dart index ad214bd1040..1b5c0eb7227 100644 --- a/packages/flame_texturepacker/lib/flame_texturepacker.dart +++ b/packages/flame_texturepacker/lib/flame_texturepacker.dart @@ -9,9 +9,20 @@ export 'package:flame_texturepacker/src/texture_packer_sprite.dart'; extension TexturepackerLoader on Game { /// Loads the specified pack file. /// Uses the parent directory of the pack file to find the page images. + @Deprecated('Use [atlasFromAssets] or [atlasFromStorage] instead') Future fromAtlas( String assetsPath, { bool fromStorage = false, }) async => TexturePackerAtlas.load(assetsPath, fromStorage: fromStorage); + + /// Loads the specified pack file from assets + /// Uses the parent directory of the pack file to find the page images. + Future atlasFromAssets(String assetsPath) async => + TexturePackerAtlas.load(assetsPath); + + /// Loads the specified pack file from storage + /// Uses the parent directory of the pack file to find the page images. + Future atlasFromStorage(String storagePath) async => + TexturePackerAtlas.load(storagePath, fromStorage: true); }