Giter VIP home page Giter VIP logo

bevy-prototype-parallax's Introduction

bevy-prototype-parallax

A simple parallax component for the bevy engine.

This will allow you to quickly have a scrolling parralax style background. It should also be useable to have a simple scrolling background too.

It does assume your image repeats nicely infinitely

Demo

Usage

    App::build()
        ....
        .add_plugin(ParallaxPlugin)

    ....
    let handle = /*load your colormaterial */

    commands
        .spawn(Camera2dComponents::default())
        .with(WindowSize::default())
        .with_children(|cb| {
            // Spawn the layers.
            // We can have as many as we like
            cb.spawn(LayerComponents {
                layer: Layer {
                    speed: speed,
                },
                material: handle,                                                                                
                ..Default::default()
        });

Make sure your camera has a window size component. This will enable a system that allows, the window size to be known, which allows the plugin to determine how many times to repeat the image.

Then make sure your layer uses this camera as it's parent element. This allows it so shift itself depending on how much the camera is offset. Different speeds off different layers will achieve a repeating effect, a speed of 0 will make the layer static, a speed of 1.0 will make it move linearly with the camera.

The sprite components are managed automatically by the layer system, it will only spawn as many as needed to fill the screen.

Note: doesn't support resizing yet. Note: only horizontal for now.

bevy-prototype-parallax's People

Contributors

btrepp avatar theashguy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.