Expand description

License: MIT Crates.io docs

§Bevy Tiled Camera

A camera for properly displaying low resolution pixel perfect 2D games in bevy. It works by adjusting the viewport to match a target resolution, which is defined by a tile count and the number of pixels per tile.

§Example

use bevy_tiled_camera::*;
use bevy::prelude::*;

fn setup(mut commands:Commands) {
  // Sets up a camera to display 80 x 35 tiles.
  // Defaults to 8 pixels per tile.
  let camera_bundle = TiledCameraBundle::unit_cam([80,35]);

  commands.spawn(camera_bundle);
}

fn main() {
    App::new()
    .add_plugins((DefaultPlugins, TiledCameraPlugin))
    .add_systems(Startup, setup)
    .run();
}

§World Space

Your world space defines how transforms and scaling is treated in your game. You can choose between WorldSpace::Units or WorldSpace::Pixels. The camera supports either, and it’s up to you to decide which you prefer.

§Versions

bevybevy_tiled_camera
0.130.9.0
0.120.8.0
0.110.7.0
0.100.6.0
0.90.5.0
0.80.4.0
0.60.3.0
0.50.2.4
0.50.2.3

§Blurry sprites

By default bevy will create all new images with linear image sampling. This is good for smaller, high resolution images but causes severe blurriness with low resolution images. To fix it you can manually set the image sampler to nearest when creating your images, or change the default to always spawn new images with nearest sampling:

use bevy::prelude::*;
use bevy_tiled_camera::*;


App::new()
// Must be inserted during app initialization, before rendering plugins
.add_plugins((
    DefaultPlugins.set(ImagePlugin::default_nearest()),
    TiledCameraPlugin,
))
.run();

Structs§

Enums§