zerker 1.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

pub package

What is Zerker #

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.

More detailed documentation about Zerker is here https://flutterkit.github.io/zerkerdocs/

An image

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);

More cases #

You can quickly start learning an example here. https://flutterkit.github.io/zerkerdocs/guide/tutorial.html

More zerker examples you can view here https://github.com/flutterkit/zerker-samples. If you have any questions about Zerker, please let me know by email, thank you very much!

License #

Zerker is licensed under MIT license. View license. https://github.com/flutterkit/zerker/blob/master/LICENSE

1.3.2 #

  • Fix ZKContainer removeChild bug
  • Fix Assets onProgress bug

1.3.1 #

  • Remove uuid library dependencies
  • Fix some bugs

1.3.0 #

  • fix ZKTween chain bug
  • Rewrite example
  • Optimize tap interaction events
  • Adjust multiple built-in function structures
  • Modify the ZKScrollBg class to increase the play/stop method
  • add fps Attribute

1.2.8 #

  • fix a sprite sheet bug
  • flutter format code

1.2.7 #

  • Add new logo

1.2.6 #

  • Add example
  • Add detailed documentation
  • Increase readme

1.2.5 #

  • Add three extension classes
  • First full version

1.2.0 #

  • Increase sprite sheet support
  • Increase atlas support
  • Add animation

1.1.0 #

  • Create a base version, including ZKNode ZKImage, etc.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:zerker/zerker.dart';
//import './zerker.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Zerker Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Zerker Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

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

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),
        ));
  }
}

class MyZKApp extends ZKApp {
  bool _loaded = false;
  bool _jumping = false;
  ZKSprite boy;
  ZKText title;
  ZKScrollBg bg;

  @override
  init() {
    super.init();
    stage.color = Colors.blueGrey;

    Map<String, dynamic> urls = {
      "boy": {"json": "assets/boy.json", "image": "assets/boy.png"},
      "bg": "assets/bg.png",
    };

    // preload all assets
    ZKAssets.preload(
        urls: urls,
        onProgress: (scale) {
          print("Assets loading ${scale * 100}%");
        },
        onLoad: () {
          initScene();
          _loaded = true;
          print("Assets load Complete");
        });
  }

  initScene() {
    // add title
    title = ZKText()
      ..position.x = appWidth / 2
      ..position.y = 20
      ..text = "Please click anywhere"
      ..setStyle(color: Colors.blueGrey, backgroundColor: Colors.greenAccent, textAlign: TextAlign.center);
    stage.addChild(title);

    // add boy
    boy = ZKSprite(key: "boy")
      ..setScale(1)
      ..anchor.y = 1
      ..position.x = size.width / 2
      ..position.y = appHeight - 16
      ..animator.make("run", ["Run ({1-15}).png"])
      ..animator.make("jump", ["Jump ({1-15}).png"])
      ..animator.make("dead", ["Dead ({1-15}).png"])
      ..animator.play("run", 25, true);
    stage.addChild(boy);

    // add bg
    bg = ZKScrollBg(key: "bg", time: 4 * 1000)
      ..setScale(0.5)
      ..position.y = appHeight
      ..anchor.y = 1;
    stage.addChildAt(bg, 0);

    _addAction();
  }

  _addAction() {
    boy.onTapDown = (event) {
      bg.stop();
      _jumping = false;
      boy.animator.play("dead", 20);
    };

    stage.onTapDown = (event) {
      if (event.target == boy) return;
      if (_jumping) return;

      bg.play();
      _jumping = true;
      boy.animator.play("jump", 20);
      ZKTween(boy)
          .to({"y": appHeight - 120}, 500)
          .easing(Ease.circ.easeOut)
          .chain(ZKTween(boy).to({"y": appHeight - 16}, 500).easing(Ease.circ.easeIn).onComplete((obj) {
                boy.animator.play("run", 25, true);
                _jumping = false;
              }))
          .start();
    };
  }

  @override
  update(int time) {
    if (!_loaded) return;
    super.update(time);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  zerker: ^1.3.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:zerker/zerker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test