Skip to content

mirsella/bevy_tiled_background

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_tiled_background

Crates.io Docs.rs License

A Bevy plugin for creating tiled, animated UI backgrounds with support for rotation, staggering, spacing, and scrolling animation.

Example

Features

  • Responsive tiling - Tiles maintain constant pixel size; more tiles appear on larger screens
  • Aspect ratio preservation - Images never stretch
  • Rotation - Rotate the entire pattern
  • Row staggering - Create brick-like offset patterns
  • Spacing - Add gaps between tiles
  • Scrolling animation - Smooth horizontal/vertical movement

Installation

cargo add bevy_tiled_background

Or add to your Cargo.toml:

[dependencies]
bevy_tiled_background = "0.3"

Usage

use bevy::prelude::*;
use bevy_tiled_background::{TiledBackgroundPlugin, TiledBackgroundMaterial};

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

fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<TiledBackgroundMaterial>>,
) {
    commands.spawn(Camera2d);

    let material = materials.add(TiledBackgroundMaterial {
        color: LinearRgba::WHITE,
        scale: 0.5,
        rotation: 35f32.to_radians(),
        stagger: 0.5,
        spacing: 0.8,
        scroll_speed: Vec2::new(20.0, 0.0),
        pattern_texture: asset_server.load("my_pattern.png"),
    });

    commands.spawn((
        Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            ..default()
        },
        MaterialNode(material),
    ));
}

Material Properties

Property Type Description
color LinearRgba Tint multiplied with the texture (WHITE = no tint, alpha controls opacity)
scale f32 Size multiplier (1.0 = native texture size)
rotation f32 Rotation angle in radians
stagger f32 Row offset (0.5 = half-tile shift for brick pattern)
spacing f32 How much of each tile the image fills (0.0-1.0)
scroll_speed Vec2 Animation speed in pixels per second
pattern_texture Handle<Image> The texture to tile

Bevy Compatibility

bevy bevy_tiled_background
0.17 0.3

License

Licensed under either of:

at your option.

About

Bevy plugin for animated, tiled UI backgrounds with rotation, staggering, and scrolling

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors