CineCam2D is a 2D camera library for games and other interactive applications built on top of Bevy. Add features like focus, bounding box, panning, shake, and zoom to your Bevy application with ease.
- Focus: Camera focus/tracking on a single or on multiple entities, with optional smoothing.
- Bounding Box (
bound
feature): Constrain camera within a bounding box. - Panning (
pan
feature): Manual camera panning. - Zooming (
zoom
feature): Manual camera zooming. - Shake (
shake
feature): Camera shake effects using random noise.
Add cinecam2d
to your Cargo.toml
:
[dependencies]
cinecam2d = "0.1.0"
The features in this library are optional, you can enable them by adding the following to your Cargo.toml
. The focus
feature is enabled by default.
[dependencies]
cinecam2d = { version = "0.1.0", features = ["bound", "pan", "shake", "zoom"] }
Add cinecam2d
to your Bevy app:
cargo run --example basic
use bevy::prelude::*;
use cinecam2d::CineCam2DPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Use this instead for pixel perfect rendering
// .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins(CineCam2DPlugin)
.add_systems(Startup, world_setup)
.run();
}
fn world_setup(mut commands: Commands) {
cinecam2d::init(&mut commands, Transform::from_xyz(0.0, 0.0, 10.0));
}
Check the example for more settings.
cargo run --example focus
Focusing on multiple entities work the same way, just add the FocusTarget
component to each entity.
Check the example for more settings.
cargo run --example bound
Check the example for more settings.
cargo run --example pan
Check the example for more settings.
cargo run --example zoom
Check the example for more settings.
cargo run --example shake
This project is under the MIT License - see the LICENSE.md file for details.