flame_camera_tools 0.0.1 copy "flame_camera_tools: ^0.0.1" to clipboard
flame_camera_tools: ^0.0.1 copied to clipboard

Inituitive camera management for Flame.

flame_camera_tools #

flame_camera_tools is a Flutter package that enhances camera functionality for games built with Flame. It provides a intuitive way to manage camera behavior, making it easier to create dynamic and immersive experiences in 2D game worlds.

Features #

  • Smooth Follow: The camera smoothly follows a target component, adjusting the speed based on the distance.
  • Shake Effect: Apply a shake effect to any PositionProvider.
  • Zooming: Zoom in or out with customizable durations.
  • Focus Effects: Focus the camera on a position or component.
  • Customizable Effects: Modify the duration and curve of each effect.
  • Chaining Effects: Seamlessly chain multiple effects using Futures.

CameraComponent Extension Methods #

  • smoothFollow() – Smoothly follows a ReadOnlyPositionProvider with adjustable stiffness.
  • shake() – Apply a shake effect to the camera.
  • zoomTo() – Zoom in or out with a customizable duration and curve.
  • focusOn() – Focus on a particular position in the world.
  • focusOnComponent() – Focus on a specific component.

Usage #

Import the package like this:

import 'package:flame_camera_tools/flame_camera_tools.dart';
copied to clipboard

Instantiate you camera component using Flame:

final camera = CameraComponent();
copied to clipboard

Follow a Component:

camera.smoothFollow(component, stiffness: 5);
copied to clipboard

Apply a Shake Effect:

camera.shake(
  duration: const Duration(seconds: 3),
  intensity: 5,
  curve: Curves.linear,
);
copied to clipboard

Zoom Out:

camera.zoomTo(
  0.5,
  duration: const Duration(seconds: 3),
  curve: Curves.linear,
);
copied to clipboard

Focus on a Component:

camera.focusOnComponent(
  component,
  duration: const Duration(seconds: 3),
  curve: Curves.linear,
);
copied to clipboard

Chaining Multiple Effects:

camera
    .shake(duration: const Duration(seconds: 4), intensity: 10)
    .then((_) => camera.zoomTo(0.1, duration: const Duration(seconds: 3)))
    .then((_) => camera.focusOnComponent(component, duration: Duration(seconds: 3)))
    .then((_) => camera.zoomTo(1.0, duration: const Duration(seconds: 2)));
copied to clipboard

Applying Multiple Effects at Once:

camera
  ..shake(duration: const Duration(seconds: 4), intensity: 7)
  ..zoomTo(0.75, duration: const Duration(seconds: 2));
copied to clipboard

Why Use This Package? #

This package allows for easy and smooth camera transitions, such as when you want to zoom in on an action, create a shake effect for a hit or explosion, or follow a character smoothly as they move through a level. The effects are customizable and can be chained to create complex camera behaviors that enhance your game's dynamic visuals.

10
likes
0
points
97
downloads

Publisher

verified publisherbszarlej.de

Weekly Downloads

2024.09.13 - 2025.03.28

Inituitive camera management for Flame.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flame, flutter

More

Packages that depend on flame_camera_tools