flexible and lightweight flutter
zerker is a flexible and lightweight flutter canvas graphic animation library.
with zerker, you can create a lot of seemingly cumbersome animation effects, such as animated animations, pop-up animations, scene transitions, icon effects, and more.
at the same time, you can create a lot of simple games with zerker. zerker contains elements such as sprites, scrolling backgrounds, and atlases, making it easy to create game worlds with them.
installation
add this to your package’s pubspec.yaml file, and execute the commandflutter pub get
:
dependencies:
zerker: <latest_version_here>
more detailed installation steps, you can refer to here. https://pub.dev/packages/zerker#-installing-tab-
getting started
import the package
import 'package:zerker/zerker.dart';
useage
create a zerker widget
class _myhomepagestate extends state<myhomepage> {
@override
widget build(buildcontext context) {
return scaffold(
appbar: appbar(
title: text(widget.title),
),
body: center(
child: zerker(app: myzkapp(), clip: true, interactive: true, width: 350, height: 350),
));
}
}
create your zerker class inherited from zkapp
class myzkapp extends zkapp {
@override
init() {
super.init();
/// init zerker scene
}
@override
update(int time) {
super.update(time);
sprite.position.x++;
}
}
initialize the scene and create elements in the init function
/// create a zerker sprite
zksprite bigboy = zksprite(key: "bigboy")
..position.x = size.width / 2
..position.y = size.height / 2
..animator.make("front", [0, 1, 2, 3, 4])
..animator.make("left", ['5-9'])
..animator.make("after", ['10-14'])
..animator.make("right", ['15-19'])
..ontapdown = (event) {
bigboy.animator.play("right", 8, true);
};
stage.addchild(bigboy);
/// create a zerker text
zktext text = zktext()
..setposition(100, 100)
..text = "hello world"
..setstyle(color: colors.bluegrey, backgroundcolor: colors.red[50]);
stage.addchild(_text);
Comments are closed.