Skip to content
프로젝트

소개

직교 카메라를 이동하는 Bevy 플러그인

기타 프로젝트

이 수치를 측정하는 방법

What you can do

  • bevy_egui_<major>_<minor> makes pancam cameras not react when the mouse or keyboard focus is on widgets created with the specific bevy_egui release. The feature is suffixed with the egui version because bevy_egui typically releases multiple breaking versions per Bevy release, and we don't want to be forced to break on every bevy_egui release.

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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
  • Hold keyboard buttons to move the camera

Usage

Add the plugin to your app

App::new()
    .add_plugins((DefaultPlugins, PanCamPlugin::default()))
    .run();

Add the component to an orthographic camera:

commands.spawn((
    Camera2d,
    PanCam::default(),
))

This is enough to get going with sensible defaults.

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

commands.spawn((
    Camera2d,
    PanCam {
        grab_buttons: vec![MouseButton::Left, MouseButton::Middle], // which buttons should drag the camera
        move_keys: DirectionKeys {      // the keyboard buttons used to move the camera
            up:    vec![KeyCode::KeyQ], // initalize the struct like this or use the provided methods for
            down:  vec![KeyCode::KeyW], // common key combinations
            left:  vec![KeyCode::KeyE],
            right: vec![KeyCode::KeyR],
        },
        speed: 400., // the speed for the keyboard movement
        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: 40., // prevent the camera from zooming too far out
        min_x: f32::NEG_INFINITY, // minimum x position of the camera window
        max_x: f32::INFINITY, // maximum x position of the camera window
        min_y: f32::NEG_INFINITY, // minimum y position of the camera window
        max_y: f32::INFINITY, // maximum y position of the camera window
    },
));

See the simple and toggle examples.

Cargo features

  • bevy_egui_<major>_<minor> makes pancam cameras not react when the mouse or keyboard focus is on widgets created with the specific bevy_egui release. The feature is suffixed with the egui version because bevy_egui typically releases multiple breaking versions per Bevy release, and we don't want to be forced to break on every bevy_egui release.

Bevy Version Support

The main branch targets the latest bevy release.

bevy bevy_pancam
0.20 0.22, main
0.19 0.21
0.18 0.20
0.17 0.19
0.16 0.18
0.15 0.16, 0.17
0.14 0.12, 0.13, 0.14, 0.15
0.13 0.11
0.12 0.10
0.11 0.9
0.10 0.8
0.9 0.7,
0.8 0.5, 0.6
0.7 0.3, 0.4
0.6 0.2
0.5 0.1

License

bevy_pancam is dual-licensed under either

at your option.

Contributions

PRs welcome!

관련 프로젝트 살펴보기

불러오는 중…