Crate bevy_tiled_camera[][src]

Expand description

A simple camera for properly displaying low resolution pixel perfect 2D games in bevy.

This camera will scale up the viewport as much as possible while mainting your target resolution and avoiding pixel artifacts.

Example

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

fn setup(mut commands:Commands) {
  // Sets up a camera to display 80 x 25 tiles. The viewport will be scaled up
  // as much as possible to fit the window size and maintain the appearance of
  // 8 pixels per tile.
  let camera_bundle = TiledCameraBundle::new()
      .with_pixels_per_tile(8)
      .with_tile_count((80,25));

  commands.spawn_bundle(camera_bundle);
}

fn main() {
    App::build()
    .add_plugins(DefaultPlugins)
    .add_plugin(TiledCameraPlugin)
    .add_startup_system(setup.system())
    .run();
}

Note this is only half the work needed to avoid artifacts with low resolution pixel art. You also need to ensure the camera position and your sprite edges are aligned to the pixel grid.

There is currently a bug in bevy version 0.5 where the camera projection does not update unless you actively resize the window.

Structs

Component bundle with functions to specify how you want the camera set up.

Plugin which initializes the camera update function.

A camera projection which divides the view into a set number of tiles.