Skip to content

Commit 17bc40c

Browse files
authored
feat!: Support Spine 4.3 (#3760)
As-is, the existing `flame_spine` supports Spine 4.2. `spine_flutter` in 4.3.0 now supports Spine 4.3, and this is backwards incompatible and breaking. If you need Spine 4.2, you should not upgrade to `flame_spine` 0.3.0, but this is for anyone who is ready to make the Spine 4.3 jump. We recommend pinning to 0.2.2 for `spine_flutter` 4.2.36 if you are staying on Spine 4.2. The top-level API has many breaking changes, and this changelog has a good summary of what needs to be done: https://pub.dev/packages/spine_flutter/changelog The Dart code changes are relatively straightforward, but any Spine models need to be re-exported through the 4.3 Spine Editor (and you SHOULD make sure that all models still do everything that is expected! There might be random bones that don't look right any more, random animations, and certain models just don't work.) Dart API changes: https://pub.dev/packages/spine_flutter/changelog Re-export at 4.2 Spine models from the 4.3 Spine Editor and confirm each model works.
1 parent e06260d commit 17bc40c

File tree

12 files changed

+4292
-4194
lines changed

12 files changed

+4292
-4194
lines changed

examples/assets/spine/spineboy-pro.json

Lines changed: 4166 additions & 4091 deletions
Large diffs are not rendered by default.
257 Bytes
Binary file not shown.

examples/assets/spine/spineboy.atlas

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,96 @@ spineboy.png
33
filter: Linear, Linear
44
scale: 0.5
55
crosshair
6-
bounds: 352, 7, 45, 45
6+
bounds: 263, 11, 45, 45
77
eye-indifferent
8-
bounds: 862, 105, 47, 45
8+
bounds: 214, 11, 47, 45
99
eye-surprised
10-
bounds: 505, 79, 47, 45
10+
bounds: 965, 33, 47, 45
11+
rotate: 90
1112
front-bracer
12-
bounds: 826, 66, 29, 40
13+
bounds: 2, 5, 29, 40
14+
rotate: 90
1315
front-fist-closed
14-
bounds: 786, 65, 38, 41
16+
bounds: 505, 3, 38, 41
17+
rotate: 90
1518
front-fist-open
16-
bounds: 710, 51, 43, 44
19+
bounds: 790, 9, 43, 44
1720
rotate: 90
1821
front-foot
19-
bounds: 210, 6, 63, 35
22+
bounds: 149, 21, 63, 35
2023
front-shin
21-
bounds: 665, 128, 41, 92
24+
bounds: 505, 43, 41, 92
2225
rotate: 90
2326
front-thigh
24-
bounds: 2, 2, 23, 56
27+
bounds: 359, 14, 23, 56
2528
rotate: 90
2629
front-upper-arm
27-
bounds: 250, 205, 23, 49
30+
bounds: 955, 8, 23, 49
31+
rotate: 90
2832
goggles
29-
bounds: 665, 171, 131, 83
33+
bounds: 180, 58, 131, 83
3034
gun
31-
bounds: 798, 152, 105, 102
35+
bounds: 313, 39, 105, 102
3236
head
33-
bounds: 2, 27, 136, 149
37+
bounds: 29, 83, 136, 149
38+
rotate: 90
3439
hoverboard-board
35-
bounds: 2, 178, 246, 76
40+
bounds: 180, 143, 246, 76
3641
hoverboard-thruster
37-
bounds: 722, 96, 30, 32
38-
rotate: 90
42+
bounds: 790, 57, 30, 32
3943
hoverglow-small
40-
bounds: 275, 81, 137, 38
44+
bounds: 826, 54, 137, 38
4145
mouth-grind
42-
bounds: 614, 97, 47, 30
46+
bounds: 707, 8, 47, 30
4347
mouth-oooo
44-
bounds: 612, 65, 47, 30
48+
bounds: 658, 8, 47, 30
4549
mouth-smile
46-
bounds: 661, 64, 47, 30
50+
bounds: 548, 11, 47, 30
4751
muzzle-glow
48-
bounds: 382, 54, 25, 25
52+
bounds: 997, 194, 25, 25
4953
muzzle-ring
50-
bounds: 275, 54, 25, 105
51-
rotate: 90
54+
bounds: 2, 114, 25, 105
5255
muzzle01
53-
bounds: 911, 95, 67, 40
56+
bounds: 965, 82, 67, 40
5457
rotate: 90
5558
muzzle02
56-
bounds: 792, 108, 68, 42
57-
muzzle03
58-
bounds: 956, 171, 83, 53
59+
bounds: 953, 151, 68, 42
5960
rotate: 90
61+
muzzle03
62+
bounds: 420, 31, 83, 53
6063
muzzle04
61-
bounds: 275, 7, 75, 45
64+
bounds: 2, 36, 75, 45
6265
muzzle05
63-
bounds: 140, 3, 68, 38
66+
bounds: 79, 43, 68, 38
6467
neck
65-
bounds: 250, 182, 18, 21
68+
bounds: 997, 171, 18, 21
6669
portal-bg
67-
bounds: 140, 43, 133, 133
70+
bounds: 563, 86, 133, 133
6871
portal-flare1
69-
bounds: 554, 65, 56, 30
72+
bounds: 79, 11, 56, 30
7073
portal-flare2
71-
bounds: 759, 112, 57, 31
72-
rotate: 90
74+
bounds: 836, 21, 57, 31
7375
portal-flare3
74-
bounds: 554, 97, 58, 30
76+
bounds: 895, 22, 58, 30
7577
portal-shade
76-
bounds: 275, 121, 133, 133
78+
bounds: 428, 86, 133, 133
7779
portal-streaks1
78-
bounds: 410, 126, 126, 128
80+
bounds: 698, 91, 126, 128
7981
portal-streaks2
80-
bounds: 538, 129, 125, 125
82+
bounds: 826, 94, 125, 125
8183
rear-bracer
82-
bounds: 857, 67, 28, 36
84+
bounds: 756, 2, 28, 36
8385
rear-foot
84-
bounds: 663, 96, 57, 30
86+
bounds: 599, 14, 57, 30
8587
rear-shin
86-
bounds: 414, 86, 38, 89
88+
bounds: 599, 46, 38, 89
8789
rotate: 90
8890
rear-thigh
89-
bounds: 756, 63, 28, 47
91+
bounds: 310, 9, 28, 47
92+
rotate: 90
9093
rear-upper-arm
91-
bounds: 60, 5, 20, 44
94+
bounds: 417, 9, 20, 44
9295
rotate: 90
9396
torso
94-
bounds: 905, 164, 49, 90
97+
bounds: 698, 40, 49, 90
98+
rotate: 90

examples/assets/spine/spineboy.png

-4.54 KB
Loading

examples/lib/stories/bridge_libraries/flame_spine/basic_spine_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ class FlameSpineExample extends FlameGame with TapCallbacks {
4040
);
4141

4242
// Set the "walk" animation on track 0 in looping mode
43-
spineboy.animationState.setAnimationByName(0, 'walk', true);
43+
spineboy.animationState.setAnimation(0, 'walk', true);
4444
await add(spineboy);
4545
}
4646

4747
@override
4848
void onTapDown(_) {
4949
_stateIndex = (_stateIndex + 1) % states.length;
50-
spineboy.animationState.setAnimationByName(0, states[_stateIndex], true);
50+
spineboy.animationState.setAnimation(0, states[_stateIndex], true);
5151
}
5252

5353
@override

examples/lib/stories/bridge_libraries/flame_spine/shared_data_spine_example.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class SharedDataSpineExample extends FlameGame with TapCallbacks {
1010
components.
1111
''';
1212

13-
late final SkeletonData cachedSkeletonData;
14-
late final Atlas cachedAtlas;
13+
late final SkeletonDataFlutter cachedSkeletonData;
14+
late final AtlasFlutter cachedAtlas;
1515
late final List<SpineComponent> spineboys = [];
1616

1717
@override
1818
Future<void> onLoad() async {
1919
await initSpineFlutter();
2020
// Pre-load the atlas and skeleton data once.
21-
cachedAtlas = await Atlas.fromAsset('assets/spine/spineboy.atlas');
22-
cachedSkeletonData = await SkeletonData.fromAsset(
21+
cachedAtlas = await AtlasFlutter.fromAsset('assets/spine/spineboy.atlas');
22+
cachedSkeletonData = await SkeletonDataFlutter.fromAsset(
2323
cachedAtlas,
2424
'assets/spine/spineboy-pro.skel',
2525
);
@@ -30,15 +30,19 @@ class SharedDataSpineExample extends FlameGame with TapCallbacks {
3030
// atlas.
3131
final rng = Random();
3232
for (var i = 0; i < 100; i++) {
33-
final drawable = SkeletonDrawable(cachedAtlas, cachedSkeletonData, false);
33+
final drawable = SkeletonDrawableFlutter(
34+
cachedAtlas,
35+
cachedSkeletonData,
36+
false,
37+
);
3438
final scale = 0.1 + rng.nextDouble() * 0.2;
3539
final position = Vector2.random(rng)..multiply(size);
3640
final spineboy = SpineComponent(
3741
drawable,
3842
scale: Vector2.all(scale),
3943
position: position,
4044
);
41-
spineboy.animationState.setAnimationByName(0, 'walk', true);
45+
spineboy.animationState.setAnimation(0, 'walk', true);
4246
spineboys.add(spineboy);
4347
}
4448
await addAll(spineboys);
@@ -47,10 +51,10 @@ class SharedDataSpineExample extends FlameGame with TapCallbacks {
4751
@override
4852
void onTapDown(_) {
4953
for (final spineboy in spineboys) {
50-
spineboy.animationState.setAnimationByName(0, 'jump', false);
54+
spineboy.animationState.setAnimation(0, 'jump', false);
5155
spineboy.animationState.setListener((type, track, event) {
5256
if (type == EventType.complete) {
53-
spineboy.animationState.setAnimationByName(0, 'walk', true);
57+
spineboy.animationState.setAnimation(0, 'walk', true);
5458
}
5559
});
5660
}

packages/flame_spine/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ conditions of the Spine Runtime License Agreement (see the LICENSE file).
1515

1616
**In particular, in order to use `flame_spine` you are required to obtain a valid Spine Editor
1717
License.**
18+
19+
20+
## Spine 4.2 vs Spine 4.3
21+
22+
Make sure that you are using the right version of `flame_spine` for your current version of the
23+
Spine Editor.
24+
25+
For Spine 4.2, `v0.2.2` is the last release. Spine 4.3 support begins with `v0.3.0`.
26+
27+
To migrate from 4.2 to 4.3 models, make sure to re-export any existing 4.2 models through the 4.3
28+
Spine Editor, and follow the `spine_flutter` [migration guide](https://pub.dev/packages/spine_flutter/changelog).
257 Bytes
Binary file not shown.

packages/flame_spine/example/assets/spineboy.atlas

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,96 @@ spineboy.png
33
filter: Linear, Linear
44
scale: 0.5
55
crosshair
6-
bounds: 352, 7, 45, 45
6+
bounds: 263, 11, 45, 45
77
eye-indifferent
8-
bounds: 862, 105, 47, 45
8+
bounds: 214, 11, 47, 45
99
eye-surprised
10-
bounds: 505, 79, 47, 45
10+
bounds: 965, 33, 47, 45
11+
rotate: 90
1112
front-bracer
12-
bounds: 826, 66, 29, 40
13+
bounds: 2, 5, 29, 40
14+
rotate: 90
1315
front-fist-closed
14-
bounds: 786, 65, 38, 41
16+
bounds: 505, 3, 38, 41
17+
rotate: 90
1518
front-fist-open
16-
bounds: 710, 51, 43, 44
19+
bounds: 790, 9, 43, 44
1720
rotate: 90
1821
front-foot
19-
bounds: 210, 6, 63, 35
22+
bounds: 149, 21, 63, 35
2023
front-shin
21-
bounds: 665, 128, 41, 92
24+
bounds: 505, 43, 41, 92
2225
rotate: 90
2326
front-thigh
24-
bounds: 2, 2, 23, 56
27+
bounds: 359, 14, 23, 56
2528
rotate: 90
2629
front-upper-arm
27-
bounds: 250, 205, 23, 49
30+
bounds: 955, 8, 23, 49
31+
rotate: 90
2832
goggles
29-
bounds: 665, 171, 131, 83
33+
bounds: 180, 58, 131, 83
3034
gun
31-
bounds: 798, 152, 105, 102
35+
bounds: 313, 39, 105, 102
3236
head
33-
bounds: 2, 27, 136, 149
37+
bounds: 29, 83, 136, 149
38+
rotate: 90
3439
hoverboard-board
35-
bounds: 2, 178, 246, 76
40+
bounds: 180, 143, 246, 76
3641
hoverboard-thruster
37-
bounds: 722, 96, 30, 32
38-
rotate: 90
42+
bounds: 790, 57, 30, 32
3943
hoverglow-small
40-
bounds: 275, 81, 137, 38
44+
bounds: 826, 54, 137, 38
4145
mouth-grind
42-
bounds: 614, 97, 47, 30
46+
bounds: 707, 8, 47, 30
4347
mouth-oooo
44-
bounds: 612, 65, 47, 30
48+
bounds: 658, 8, 47, 30
4549
mouth-smile
46-
bounds: 661, 64, 47, 30
50+
bounds: 548, 11, 47, 30
4751
muzzle-glow
48-
bounds: 382, 54, 25, 25
52+
bounds: 997, 194, 25, 25
4953
muzzle-ring
50-
bounds: 275, 54, 25, 105
51-
rotate: 90
54+
bounds: 2, 114, 25, 105
5255
muzzle01
53-
bounds: 911, 95, 67, 40
56+
bounds: 965, 82, 67, 40
5457
rotate: 90
5558
muzzle02
56-
bounds: 792, 108, 68, 42
57-
muzzle03
58-
bounds: 956, 171, 83, 53
59+
bounds: 953, 151, 68, 42
5960
rotate: 90
61+
muzzle03
62+
bounds: 420, 31, 83, 53
6063
muzzle04
61-
bounds: 275, 7, 75, 45
64+
bounds: 2, 36, 75, 45
6265
muzzle05
63-
bounds: 140, 3, 68, 38
66+
bounds: 79, 43, 68, 38
6467
neck
65-
bounds: 250, 182, 18, 21
68+
bounds: 997, 171, 18, 21
6669
portal-bg
67-
bounds: 140, 43, 133, 133
70+
bounds: 563, 86, 133, 133
6871
portal-flare1
69-
bounds: 554, 65, 56, 30
72+
bounds: 79, 11, 56, 30
7073
portal-flare2
71-
bounds: 759, 112, 57, 31
72-
rotate: 90
74+
bounds: 836, 21, 57, 31
7375
portal-flare3
74-
bounds: 554, 97, 58, 30
76+
bounds: 895, 22, 58, 30
7577
portal-shade
76-
bounds: 275, 121, 133, 133
78+
bounds: 428, 86, 133, 133
7779
portal-streaks1
78-
bounds: 410, 126, 126, 128
80+
bounds: 698, 91, 126, 128
7981
portal-streaks2
80-
bounds: 538, 129, 125, 125
82+
bounds: 826, 94, 125, 125
8183
rear-bracer
82-
bounds: 857, 67, 28, 36
84+
bounds: 756, 2, 28, 36
8385
rear-foot
84-
bounds: 663, 96, 57, 30
86+
bounds: 599, 14, 57, 30
8587
rear-shin
86-
bounds: 414, 86, 38, 89
88+
bounds: 599, 46, 38, 89
8789
rotate: 90
8890
rear-thigh
89-
bounds: 756, 63, 28, 47
91+
bounds: 310, 9, 28, 47
92+
rotate: 90
9093
rear-upper-arm
91-
bounds: 60, 5, 20, 44
94+
bounds: 417, 9, 20, 44
9295
rotate: 90
9396
torso
94-
bounds: 905, 164, 49, 90
97+
bounds: 698, 40, 49, 90
98+
rotate: 90

packages/flame_spine/example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ class SpineExample extends FlameGame with TapCallbacks {
4141
);
4242

4343
// Set the "walk" animation on track 0 in looping mode
44-
spineboy.animationState.setAnimationByName(0, 'walk', true);
44+
spineboy.animationState.setAnimation(0, 'walk', true);
4545
await add(spineboy);
4646
}
4747

4848
@override
4949
void onTapDown(_) {
5050
_stateIndex = (_stateIndex + 1) % states.length;
51-
spineboy.animationState.setAnimationByName(0, states[_stateIndex], true);
51+
spineboy.animationState.setAnimation(0, states[_stateIndex], true);
5252
}
5353

5454
@override

0 commit comments

Comments
 (0)