/bonfire_spine

Primary LanguageDartApache License 2.0Apache-2.0

spine runtime on bonfire

Features

spine runtime on bonfire

10.27.1.mp4

Getting started

start using the package.

Usage

dependencies: bonfire_spine: ^0.0.1

Include short and useful examples for package users. Add longer examples to `/example` folder. ```dart class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title;

@override State createState() => _MyHomePageState(); }

class _MyHomePageState extends State { @override Widget build(BuildContext context) {

return Scaffold(
  appBar: AppBar(
    // Here we take the value from the MyHomePage object that was created by
    // the App.build method, and use it to set our appbar title.
    title: Text(widget.title),
  ),
  body: Center(

    child: Column(

      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        ElevatedButton(onPressed: () async{
          bool loaded=await load();
          if(!loaded){
            return;
          }
          SpinePlayer player=SpinePlayer(position: Vector2.all(32)*8, size: Vector2.all(32)*3, skeleton: skeleton);
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => GameTiledMapWithSpine(player: player,)),
          );
        }, child: const Text('spine'))
      ],
    ),
  ),
);

} static const String pathPrefix = 'assets/skeletons/';

String name = 'spineboy';

late Set animations; late SkeletonAnimation skeleton; Future load() async { animations = await loadAnimations(); skeleton = await loadSkeleton();

return true;

}

Future<Set> loadAnimations() async { final String skeletonFile = '$name.json'; final String s = await rootBundle.loadString('$pathPrefix$name/$skeletonFile'); final Map<String, dynamic> data = json.decode(s);

return ((data['animations'] ?? <String, dynamic>{}) as Map<String, dynamic>)
    .keys
    .toSet(); 

}

Future loadSkeleton() async => SkeletonAnimation.createWithFiles(name, pathBase: pathPrefix); }

const like = 'sample';

Additional information

https://github.com/jtakakura/spine_core
https://github.com/jtakakura/spine_flutter