flame_fire_atlas 1.6.0 copy "flame_fire_atlas: ^1.6.0" to clipboard
flame_fire_atlas: ^1.6.0 copied to clipboard

Easy to use texture atlases for the flame engine created with the fire atlas editor

example/lib/main.dart

import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
import 'package:flame_fire_atlas/flame_fire_atlas.dart';
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  final game = ExampleGame();
  runApp(GameWidget(game: game));
}

class ExampleGame extends FlameGame with TapDetector {
  late FireAtlas _atlas;

  @override
  Future<void> onLoad() async {
    _atlas = await loadFireAtlas('cave_ace.fa');
    add(
      SpriteAnimationComponent(
        size: Vector2(150, 100),
        animation: _atlas.getAnimation('shooting_ptero'),
      )..y = 50,
    );

    add(
      SpriteAnimationComponent(
        size: Vector2(150, 100),
        animation: _atlas.getAnimation('bomb_ptero'),
      )
        ..y = 50
        ..x = 200,
    );

    add(
      SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('bullet'))
        ..y = 200,
    );

    add(
      SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('shield'))
        ..x = 100
        ..y = 200,
    );

    add(
      SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('ham'))
        ..x = 200
        ..y = 200,
    );
  }

  @override
  void onTapUp(TapUpInfo info) {
    add(
      SpriteAnimationComponent(
        size: Vector2(100, 100),
        animation: _atlas.getAnimation('explosion'),
        removeOnFinish: true,
      )
        ..anchor = Anchor.center
        ..position = info.eventPosition.widget,
    );
  }
}
14
likes
160
pub points
76%
popularity

Publisher

verified publisherflame-engine.org

Easy to use texture atlases for the flame engine created with the fire atlas editor

Repository (GitHub)
View/report issues
Contributing

Topics

#flame #tools

Documentation

API reference

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

MIT (license)

Dependencies

archive, flame, flutter

More

Packages that depend on flame_fire_atlas