Skip to content

Commit

Permalink
restore debug example after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtaub committed Mar 17, 2021
1 parent a548d8a commit 200e0a6
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/ortho_debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use bevy::prelude::*;
use bevy_tiled_prototype::{DebugConfig, Object, TiledMapCenter};

// this example demonstrates debugging objects. Hit spacebar to toggle them

const SCALE: f32 = 2.0;

fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_tiled_prototype::TiledMapPlugin)
.add_system(bevy::input::system::exit_on_esc_system.system())
.add_system(toggle_debug.system())
.add_startup_system(setup.system())
.run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands
.spawn(bevy_tiled_prototype::TiledMapComponents {
map_asset: asset_server.load("ortho-map.tmx"),
center: TiledMapCenter(true),
origin: Transform::from_scale(Vec3::new(SCALE, SCALE, 1.0)),
debug_config: DebugConfig {
enabled: true,
material: None,
},
..Default::default()
})
.spawn(OrthographicCameraBundle::new_2d());
}

fn toggle_debug(keyboard_input: Res<Input<KeyCode>>, mut query: Query<&mut Visible, With<Object>>) {
for mut visible in query.iter_mut() {
if keyboard_input.just_released(KeyCode::Space) {
visible.is_visible = !visible.is_visible;
}
}
}

0 comments on commit 200e0a6

Please sign in to comment.