dragonbones_flutter 0.4.1
dragonbones_flutter: ^0.4.1 copied to clipboard
Draw DragonBones skeletal animations on a Flutter Canvas: update(dt) + render(Canvas), plus a ready-made widget and no game engine dependency.
Changelog #
0.4.1 #
Depend on dragonbones: ^0.4.0. The runtime's 0.4.0 added animated IK,
Surface bones and animation blending; this release raises the range so the
renderer actually resolves it. No renderer code had to change: a Surface
arrives already posed in the mesh, and animation blending is resolved in the
armature before the draw list is built. This is a dependency release, not an API
change.
Requires dragonbones: ^0.4.0.
0.4.0 #
Stable placement, and the newer timelines reach the Canvas.
- Build a
DragonBonesPlayerwithDragonBonesAssets—DragonBonesPlayer(armature, assets: assets)— and the image resolver is wired for you;DragonBonesAssets.createPlayer(name)builds the armature too. No manualresolveImage:ormeasureBoundscall. DragonBonesPlayer.skeletonBounds+DragonBonesAssets.measureBounds: the firstfitmeasures the union across every animation once (using a throwaway armature, so the live one is never disturbed) and caches it. Placement then stops depending on the current frame, andfitno longer builds a draw list just to place the character.fitresolves bounds as: explicitbounds, thenskeletonBounds, then the current pose —useCurrentPose: trueforces the last.fit'salignnow positions the scaled art inside the leftover space (FlutterAlignsemantics), so it touches the aligned edge without leaving the box:Alignment.bottomCenteris feet on the bottom, not half the character below.- Depend on
dragonbones: ^0.3.0, soSlotAlpha/BoneAlphaandSlotZIndexreach the Canvas (the effective alpha rides in the slot colour, the draw list arrives pre-sorted). No renderer code changed for those.
Requires dragonbones: ^0.3.0.
0.3.0 #
Placement is now the player's job. DragonBonesPlayer.fit measures the
current pose and writes scale/offset from the box you render into, so a
Flame/Bonfire component no longer computes them by hand:
player
..play('idle')
..update(0)
..fit(
size: Size(size.x, size.y),
fit: DragonBonesFit.contain,
align: Alignment.bottomCenter,
);
DragonBonesFitgainscover,fitWidthandfitHeightalongsidecontainandnone.fitalso takes an optionalboundsto pin a clip whose silhouette changes (a sword swing), and returns the bounds it fitted.computeBounds()moves from theDragonBonesPlayerGeometryextension ontoDragonBonesPlayeritself; the call site (player.computeBounds()) is unchanged.DragonBonesWidgetdelegates its own fit toplayer.fit, so the widget and a hand-written engine component place an armature with the same numbers.- The Bonfire example drops its manual
min(...)/abs()placement in favour of the method.
Requires dragonbones: ^0.2.0.
0.2.0 #
Animation events reach the player. dragonbones gained a full event system
(see its changelog); this release wires it up, so a Flutter app can react to a
footstep or to an animation finishing.
player.armature.eventDispatcher.addDBEventListener(
EventObject.COMPLETE,
(event) => setState(() => _state = 'idle'),
);
DragonBonesPlayer.updatenow advances the hub (DragonBones.advanceTime) rather than the armature. That is what makes buffered events dispatch, and it is what the official bindings do. Behaviour is unchanged for a non-zero step; a zero step (update(0), used to recompute the pose without advancing time) still takes the direct path, because the hub's clock ignores a zero step.- The headless display behind
DragonBonesAssetsnow carries a real dispatcher, soplayer.armature.eventDispatcherworks with no Flutter binding involved. - A
soundEventis delivered twice — once on the armature and once on the hub'seventManager. Hook audio in one of the two.
Requires dragonbones: ^0.2.0.
Also in this release: the arms of the 46 bundled example characters are wired to
the events, and update(0) is covered by a test.
0.1.1 #
Packaging and hygiene release after the first publish. No change to the drawing: the tests that replay every runtime fixture through the real renderer behave exactly as they did in 0.1.0.
pub.dev score fixes. The 0.1.0 archive lost 30 of its 160 pub points, all of it recoverable:
descriptionshortened from 216 to 142 characters. Pub.dev rejects anything over 180, and that single field cost the whole 10-point "validpubspec.yaml" section.- Added
example/example.dart, a small app that draws an armature with no asset files at all — the skeleton and atlas are embedded and the raster is generated in memory. That is the 10-point "package has an example" section, and it givesDragonBonesWidgeta copy-pasteable entry point. analysis_options.yamlnow also carriespackage:lints/core.yaml, the set pub.dev'spanamerges over a package's own options, plusformatter: page_width: 120. Two rules existed on pub.dev's side and nowhere on ours —strict_top_level_inferenceandunintended_html_in_doc_comment, both newer thanflutter_lints4.x — so they were unreachable from CI. They are checked now.- CI gates formatting, because pub.dev scores it.
Fixed: the README's opening DragonBones link was malformed — a duplicated
closing bracket made the destination a URL containing ](. It rendered as
broken text on the pub.dev page.
0.1.0 #
First release. Draws DragonBones skeletal animations on a Flutter Canvas
through two methods, update(dt) and render(canvas) — with no dependency on
any game engine, so the same code drops into a plain Flutter app, an engine
component, or a CustomPainter.
- Sprites (
drawImageRect) and deformable meshes (drawVertices+ImageShader), including skinned meshes with bone weights and animated FFD. - Nested child armatures flattened into the draw list, with the parent slot's transform composed onto them.
- Slot colour transforms applied through
ColorFilter.matrix, including per-channel offsets; the identity case is free. DragonBonesWidgetwithDragonBonesFit, and acomputeBounds()extension for placement and hitboxes.
Built on dragonbones 0.1.0, whose
geometry is diffed against the official DragonBones runtime across 51 assets —
757,701 numeric comparisons, 0 mismatches. This package's own tests replay every
one of those fixtures through the real renderer to prove no asset is silently
skipped.
Known limitations in this release #
Inherited from the runtime (the renderer cannot draw what is not evaluated):
- No animation events (
EventObject) — nothing can be driven from the animation. - Animated IK is ignored (static IK works).
SlotZIndexandSlotAlpha/BoneAlphatimelines are not evaluated, so animated draw order and per-slot fade will be wrong.- Path constraints and
Surfacebones are not evaluated.
Specific to this package:
Alpha,Erase,Invert,LayerandSubtractblend modes have no exact Flutter counterpart and use the closestui.BlendMode. The other nine map cleanly. No fixture uses the approximated five — unverified.- Rotated atlas entries have a code path that no fixture exercises — unverified.
- Appearance is not checked by CI. Runners have no GPU; tests rasterise and count painted pixels, which catches "wired wrong and drew nothing", not "drew it wrong".
- No benchmarks. Allocation behaviour differs from upstream because pooling was dropped.