Corrosive-Games
bevy-parallax
Rust

Parallax background plugin for Bevy

Last updated Jun 8, 2026
120
Stars
21
Forks
5
Issues
0
Stars/day
Attention Score
21
Language breakdown
No language data available.
โ–ธ Files click to expand
README

bevy-parallax

A parallax plugin for the Bevy Engine. This plugin allows you to easily create scrolling parallax backgrounds for your games.

cyberpunk

fishy

Usage

,no_run
use bevy::prelude::*;
use bevy_parallax::{
    LayerSpeed, LayerData, ParallaxCameraComponent, ParallaxMoveEvent, ParallaxPlugin, ParallaxSystems, CreateParallaxEvent
};

fn main() { let primary_window = Window { title: "Window Name".to_string(), resolution: (1280.0, 720.0).into(), resizable: false, ..default() }; App::new() .add_plugins( DefaultPlugins .set(WindowPlugin { primarywindow: Some(primarywindow), ..default() }) // Use nearest filtering so our pixel art renders clear .set(ImagePlugin::default_nearest()), ) .add_plugins(ParallaxPlugin) .addsystems(Startup, initializecamera_system) .addsystems(Update, movecamera_system.before(ParallaxSystems)) .run(); }

pub fn initializecamerasystem( mut commands: Commands, mut create_parallax: EventWriter<CreateParallaxEvent> ) { let camera = commands .spawn(Camera2d::default()) .insert(ParallaxCameraComponent::default()) .id(); let event = CreateParallaxEvent { layers_data: vec![ LayerData { speed: LayerSpeed::Horizontal(0.9), path: "cyberpunkback.png".tostring(), tile_size: UVec2::new(96, 160), cols: 1, rows: 1, scale: Vec2::splat(4.5), z: 0.0, ..default() }, LayerData { speed: LayerSpeed::Horizontal(0.6), path: "cyberpunkmiddle.png".tostring(), tile_size: UVec2::new(144, 160), cols: 1, rows: 1, scale: Vec2::splat(4.5), z: 1.0, ..default() }, LayerData { speed: LayerSpeed::Horizontal(0.1), path: "cyberpunkfront.png".tostring(), tile_size: UVec2::new(272, 160), cols: 1, rows: 1, scale: Vec2::splat(4.5), z: 2.0, ..default() }, ], camera: camera, }; create_parallax.send(event); }

pub fn movecamerasystem( keyboard_input: Res<ButtonInput<KeyCode>>, mut moveeventwriter: EventWriter<ParallaxMoveEvent>, camera_query: Query<Entity, With<Camera>>, ) { let camera = cameraquery.getsingle().unwrap(); if keyboardinput.pressed(KeyCode::KeyD) || keyboardinput.pressed(KeyCode::ArrowRight) { moveeventwriter.send(ParallaxMoveEvent { translation: Vec2::new(3.0, 0.0), rotation: 0., camera: camera, }); } else if keyboardinput.pressed(KeyCode::KeyA) || keyboardinput.pressed(KeyCode::ArrowLeft) { moveeventwriter.send(ParallaxMoveEvent { translation: Vec2::new(-3.0, 0.0), rotation: 0., camera: camera, }); } }

Compatible Bevy versions

Compatibility of bevy-parallax versions:

| Bevy version | bevy-parallax version | |:-------------|:------------------------| | 0.15 | 11 | | 0.14 | 0.9 - 0.10 | | 0.13 | 0.8 | | 0.12 | 0.7 | | 0.11 | 0.5 - 0.6 | | 0.10 | 0.4 |

Credits

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท Corrosive-Games/bevy-parallax ยท Updated daily from GitHub