GithubHelp home page GithubHelp logo

colepoirier / bevy_pancam Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johanhelsing/bevy_pancam

0.0 0.0 0.0 48 KB

A bevy plugin for panning orthographic cameras

License: Other

Rust 100.00%

bevy_pancam's Introduction

bevy_pancam

crates.io MIT/Apache 2.0 crates.io docs.rs

A 2d-camera plugin for bevy that works with orthographic cameras.

The motivation is that this could be used for something like a map editor for a 2d game.

Controls

Behaves similarly to common online map applications:

  • Click and drag to move the camera
  • Scroll to zoom

Usage

Add the plugin to your app

App::build()
    .add_plugins(DefaultPlugins)
    .add_plugin(PanCamPlugin::default());

Add the component to an orthographic camera:

commands.spawn_bundle(Camera2dBundle::default())
    .insert(PanCam::default());

This is enough to get going with sensible defaults.

Alternatively, set the fields of the PanCam component to customize behavior:

commands.spawn_bundle(Camera2dBundle::default())
    .insert(PanCam {
        grab_buttons: vec![MouseButton::Left, MouseButton::Middle], // which buttons should drag the camera
        enabled: true, // when false, controls are disabled. See toggle example.
        zoom_to_cursor: true, // whether to zoom towards the mouse or the center of the screen
        min_scale: 1., // prevent the camera from zooming too far in
        max_scale: Some(40.), // prevent the camera from zooming too far out
    });

See the simple and toggle examples.

Cargo features

  • bevy_egui makes pancam cameras not react when the mouse or keyboard focus is on widgets created with bevy_egui
  • bevy-inspector-egui makes pancam cameras be inspectable by bevy-inspector-egui

Bevy Version Support

The main branch targets the latest bevy release.

I intend to support the main branch of Bevy in the bevy-main branch.

bevy bevy_pancam
0.8 0.5, 0.6, main
0.7 0.3, 0.4
0.6 0.2
0.5 0.1

License

MIT or Apache-2.0

Contributions

PRs welcome!

bevy_pancam's People

Contributors

johanhelsing avatar zyansheep avatar tombleron avatar colepoirier avatar aspiringlich avatar escribmac avatar laundmo 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.