mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[flutter] Fix path composition when loading from assets. Requires forward slash, path.join() does not work on Windows.
This commit is contained in:
parent
1e657e8cac
commit
16c917805a
1079
spine-flutter/example/assets/dragon-ess.json
Normal file
1079
spine-flutter/example/assets/dragon-ess.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -156,7 +156,7 @@
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1300;
|
||||
LastUpgradeCheck = 1430;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
|
||||
@ -114,7 +114,7 @@ class SimpleFlameExample extends FlameGame {
|
||||
// Load the Spineboy atlas and skeleton data from asset files
|
||||
// and create a SpineComponent from them, scaled down and
|
||||
// centered on the screen
|
||||
spineboy = await SpineComponent.fromAssets("assets/spineboy.atlas", "assets/spineboy-pro.skel",
|
||||
spineboy = await SpineComponent.fromAssets("assets/spineboy.atlas", "assets/spineboy-pro.json",
|
||||
scale: Vector2(0.4, 0.4), anchor: Anchor.center, position: Vector2(size.x / 2, size.y / 2));
|
||||
|
||||
// Set the "walk" animation on track 0 in looping mode
|
||||
@ -129,6 +129,36 @@ class SimpleFlameExample extends FlameGame {
|
||||
}
|
||||
}
|
||||
|
||||
class DragonExample extends FlameGame {
|
||||
late final Atlas cachedAtlas;
|
||||
late final SkeletonData cachedSkeletonData;
|
||||
late final SpineComponent dragon;
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
cachedAtlas = await Atlas.fromAsset("assets/dragon.atlas");
|
||||
cachedSkeletonData = await SkeletonData.fromAsset(cachedAtlas, "assets/dragon-ess.json");
|
||||
final drawable = SkeletonDrawable(cachedAtlas, cachedSkeletonData, false);
|
||||
dragon = SpineComponent(
|
||||
drawable,
|
||||
scale: Vector2(0.4, 0.4),
|
||||
anchor: Anchor.center,
|
||||
position: Vector2(size.x / 2, size.y / 2 - 150),
|
||||
);
|
||||
// Set the "walk" animation on track 0 in looping mode
|
||||
dragon.animationState.setAnimationByName(0, "flying", true);
|
||||
await add(dragon);
|
||||
}
|
||||
|
||||
@override
|
||||
void onDetach() {
|
||||
// Dispose the native resources that have been loaded for spineboy.
|
||||
dragon.dispose();
|
||||
cachedSkeletonData.dispose();
|
||||
cachedAtlas.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class PreloadAndShareSpineDataExample extends FlameGame {
|
||||
late final SkeletonData cachedSkeletonData;
|
||||
late final Atlas cachedAtlas;
|
||||
|
||||
@ -143,7 +143,19 @@ class ExampleSelector extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
spacer
|
||||
spacer,
|
||||
ElevatedButton(
|
||||
child: const Text('Flame: Dragon Example'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<void>(
|
||||
builder: (context) => SpineFlameGameWidget(DragonExample()),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
spacer,
|
||||
])));
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class PlayPauseAnimationState extends State<PlayPauseAnimation> {
|
||||
appBar: AppBar(title: const Text('Play/Pause')),
|
||||
body: SpineWidget.fromAsset(
|
||||
"assets/dragon.atlas",
|
||||
"assets/dragon-ess.skel",
|
||||
"assets/dragon-ess.json",
|
||||
controller,
|
||||
boundsProvider: SkinAndAnimationBounds(animation: "flying"),
|
||||
),
|
||||
|
||||
@ -203,7 +203,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 1300;
|
||||
LastUpgradeCheck = 1430;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
33CC10EC2044A3C60003C045 = {
|
||||
|
||||
@ -21,10 +21,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
||||
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.1"
|
||||
version: "1.17.2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -114,10 +114,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -202,6 +202,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.4-beta"
|
||||
web_ffi_fork:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -211,5 +219,5 @@ packages:
|
||||
source: hosted
|
||||
version: "0.7.4"
|
||||
sdks:
|
||||
dart: ">=3.0.0 <4.0.0"
|
||||
dart: ">=3.1.0-185.0.dev <4.0.0"
|
||||
flutter: ">=3.10.5"
|
||||
|
||||
@ -126,7 +126,7 @@ class Atlas {
|
||||
final numImagePaths = _bindings.spine_atlas_get_num_image_paths(atlas);
|
||||
for (int i = 0; i < numImagePaths; i++) {
|
||||
final Pointer<Utf8> atlasPageFile = _bindings.spine_atlas_get_image_path(atlas, i).cast();
|
||||
final imagePath = path.join(atlasDir, atlasPageFile.toDartString());
|
||||
final imagePath = atlasDir + "/" + atlasPageFile.toDartString();
|
||||
var imageData = await loadFile(imagePath);
|
||||
final Codec codec = await instantiateImageCodec(imageData);
|
||||
final FrameInfo frameInfo = await codec.getNextFrame();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user