Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flutter × 2dimensions

tazake
May 31, 2018
1.2k

Flutter × 2dimensions

use NIMA of 2dimensions on Flutter

tazake

May 31, 2018
Tweet

Transcript

  1. 2D character animation tool vector animation tools for app and

    game designers alike released Coming soon as a free beta 2dimensions? %JNFOTJPOTP⒎FSTQPXFSGVMSFBMUJNFBOJNBUJPOUPPMT https:/ /www.2dimensions.com/
  2. NIMA Supported Assets Nima supports most popular image formats, image

    sequences, and PSD files (8-bit mode). Be sure to flatten any PSD layer effects before importing into Nima. PSD Imported PSDs appear as a single top-level asset (with a PSD icon), which can be expanded to reveal all the layers included in it. Image Sequences Import an image sequence into Nima by dragging and dropping multiple images that are named sequentially (e.g. image_000.png, image_0001.png, image_0002.png, etc). https:/ /www.2dimensions.com/learn/manual/assets
  3. NIMA Supported Assets Nima supports most popular image formats, image

    sequences, and PSD files (8-bit mode). Be sure to flatten any PSD layer effects before importing into Nima. PSD Imported PSDs appear as a single top-level asset (with a PSD icon), which can be expanded to reveal all the layers included in it. Image Sequences Import an image sequence into Nima by dragging and dropping multiple images that are named sequentially (e.g. image_000.png, image_0001.png, image_0002.png, etc). https:/ /www.2dimensions.com/learn/manual/assets
  4. Flutter Code dependencies: flutter: sdk: flutter nima: ^1.0.0 flutter: uses-material-design:

    true assets: - assets/BoyRun.nima - assets/BoyRun.png pubspec.yaml
  5. Flutter Code import 'package:nima/nima_actor.dart'; return new Scaffold( … body: new

    NimaActor("assets/BoyRun", alignment: Alignment.center, fit: BoxFit.contain, animation: ‘run’, mixSeconds: 0.5, completed: (String animationName) {//do something}); ); main.dart BOJNBUJPOʹ͸/*."Ͱ࡞੒ͨ͠Ξχϝʔγϣϯͷ໊લΛࢦఆ͢Δɻ
  6. nima Impelement class NimaActor extends LeafRenderObjectWidget /// A superclass for

    RenderObjectWidgets that configure RenderObject subclasses /// that have no children. abstract class LeafRenderObjectWidget extends RenderObjectWidget { … @override LeafRenderObjectElement createElement() => new LeafRenderObjectElement(this); } /// An [Element] that uses a [LeafRenderObjectWidget] as its configuration. class LeafRenderObjectElement extends RenderObjectElement { /// Creates an element that uses the given widget as its configuration. LeafRenderObjectElement(LeafRenderObjectWidget widget): super(widget); … }
  7. nima Impelement class NimaActor extends LeafRenderObjectWidget LeafRenderObjectWidget͸ࢠΛ࣋ͨͳ͍RenderObjectWidgetɻLeafRenderObjectElement͸ͦͷઃఆɻ RenderObjectWidget͸ @protected RenderObject

    createRenderObject(BuildContext context); @protected void updateRenderObject(BuildContext context, covariant RenderObject renderObject) { } createRenderObjectϝιουͰRenderObjectΛੜ੒ɺupdateRenderObjectϝιου Ͱߋ৽Λͯ͠ඳըΛ੾Γସ͍͑ͯΔײ͡ɻ ࣮ࡍͷඳըॲཧ͸RenderObject಺ͷpaintϝιουͰPaintingContext͕อ͍࣋ͯ͠Δ canvasΦϒδΣΫτ࢖༻͍ͯ͠Δɻ
  8. nima Impelement class NimaActorRenderObject extends RenderBox{ … @override void paint(PaintingContext

    context, Offset offset){ final Canvas canvas = context.canvas; … } } nima_actiorͰ͸RenderObjectΛܧঝͨ͠RenderBoxΛܧঝͯ͠NimaActorRenderObject Λ࡞੒͍ͯ͠Δɻ ※paintϝιου಺ͷcanvas΁ͷॲཧίʔυΛ࡟ͬͨΒԿ΋ඳը͞Εͳ͘ͳͬͨ ࢀর RenderObject | https://docs.flutter.io/flutter/rendering/RenderObject-class.html RenderBox | https://docs.flutter.io/flutter/rendering/RenderBox-class.html
  9. nima Impelement class NimaActor extends LeafRenderObjectWidget{ @override RenderObject createRenderObject(BuildContext context){

    return new NimaActorRenderObject() } @override void updateRenderObject(BuildContext context, covariant NimaActorRenderObject renderObject){ } } class NimaActorRenderObject extends RenderBox{ @override void paint(PaintingContext context, Offset offset){ final Canvas canvas = context.canvas; … //ඳըॲཧ } }