Support TexturePacker image atlases

This commit is contained in:
gem
2026-06-09 12:49:01 +08:00
parent e2a584d4dc
commit 38f6e0c0c9
16 changed files with 343 additions and 26 deletions

View File

@@ -10,6 +10,9 @@ void main() {
'type': 'button',
'parent': 'top_bar',
'asset': 'dice_normal',
'frame': 'dice_idle.png',
'pressedFrame': 'dice_pressed.png',
'disabledFrame': 'dice_disabled.png',
'sourceX': 4,
'sourceY': 5,
'sourceWidth': 64,
@@ -80,6 +83,9 @@ void main() {
expect(node.type, 'button');
expect(node.parent, 'top_bar');
expect(node.asset, 'dice_normal');
expect(node.frame, 'dice_idle.png');
expect(node.pressedFrame, 'dice_pressed.png');
expect(node.disabledFrame, 'dice_disabled.png');
expect(node.sourceX, 4);
expect(node.sourceY, 5);
expect(node.sourceWidth, 64);
@@ -163,6 +169,9 @@ void main() {
expect(node.textShadowOffsetX, isNull);
expect(node.textShadowOffsetY, isNull);
expect(node.textShadowBlur, isNull);
expect(node.frame, isNull);
expect(node.pressedFrame, isNull);
expect(node.disabledFrame, isNull);
expect(node.sourceX, isNull);
expect(node.sourceY, isNull);
expect(node.sourceWidth, isNull);
@@ -210,6 +219,9 @@ void main() {
'sourceY': 4,
'sourceWidth': 40,
'sourceHeight': 41,
'frame': 'piece.png',
'pressedFrame': 'piece_down.png',
'disabledFrame': 'piece_disabled.png',
'sliceLeft': 5,
'sliceTop': 6,
'sliceRight': 7,
@@ -249,6 +261,9 @@ void main() {
expect(updated.sourceY, 4);
expect(updated.sourceWidth, 40);
expect(updated.sourceHeight, 41);
expect(updated.frame, 'piece.png');
expect(updated.pressedFrame, 'piece_down.png');
expect(updated.disabledFrame, 'piece_disabled.png');
expect(updated.sliceLeft, 5);
expect(updated.sliceTop, 6);
expect(updated.sliceRight, 7);
@@ -296,19 +311,13 @@ void main() {
throwsFormatException,
);
expect(
() => RuntimeNode.fromMap({
'id': 'a',
'type': 'image',
'sourceWidth': 0,
}),
() =>
RuntimeNode.fromMap({'id': 'a', 'type': 'image', 'sourceWidth': 0}),
throwsFormatException,
);
expect(
() => RuntimeNode.fromMap({
'id': 'a',
'type': 'image',
'sliceLeft': -1,
}),
() =>
RuntimeNode.fromMap({'id': 'a', 'type': 'image', 'sliceLeft': -1}),
throwsFormatException,
);
expect(