ZKSprite constructor

ZKSprite({
  1. String? image,
  2. String? key,
  3. String? type,
  4. String? json,
  5. double width = 100,
  6. double height = 100,
})

Implementation

ZKSprite(
    {String? image,
    String? key,
    String? type,
    String? json,
    double width = 100,
    double height = 100})
    : super() {
  //this.animator = Animator();
  if (key != null) {
    this.texture = ZKAssets.getAsset(key);
    this.textureType = ZKAssets.getType(texture)!;
    if (this.texture == null)
      throw ("Zerker:: Sorry, this Key '$key' does not get any assets!");

    _timer = Timer(Duration(milliseconds: 0), () {
      this._loadComplete(this.texture!);
      _timer?.cancel();
    });
  } else if (type != null) {
    this.loadSpriteSheet(image!, Size(width, height));
    this.textureType = type;
  } else if (json != null) {
    this.loadAtlas(json, image!);
    this.textureType = "atlas";
  } else {
    this.loadImage(image!);
    this.textureType = "image";
  }
}