Skip to content

Commit 6cf33ba

Browse files
committed
Add debug demo, make objects visible in ortho map
Default points to 1.0 size objects, for fallback and visibility
1 parent 4f90abc commit 6cf33ba

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

assets/ortho-map.tmx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
eJzVl9lNw0AURZ8ltgr4YquAjliaYPl8DdAChCVABRB2KkBhpwK2sKQC4FgiShQ8tseMx/aVjmRLY+fO3JnnFxGRGZiVamkBFos2EaOBQGQw6N6PFmcltcbwOx50vU+neKYztsb1OmzAZq4uo9XxbjO2wfUBHMJRjt5c6RyacAlXcF2oGzu9wCu0YCohpwcPftJqFdZ+r9uGMf1nvWjtwX7P/UiEN5vzUiZRW5Qao9QarUHRftKI2qLUGKXWaCOjZ9/zprYoNUapNdrM+Hsu5m0jaotSY5Rao62M73Ax70d4gme4yOgjSb01tH/eu/947xd8izvfS7Ds6F2+VZP8e5oVx+8rY0/D90dN385QPnuapN7DZnxvT1O2HiCNqtYD2GaXt3aot9tQh62K9CJn+DyFEziuiOd7fN7BLdyUxDN5C7kL+Yf74I8+8fkB7/AGQ+zdYU/7t21YI/IWchfyD/dBoibwO1nwmSNvIXch/3AfxCopE18ibyF3If9wH8TKNhOfMq2nTSZ5yXSeTOvZn0nU83Mw78Bb1P/tUKbzlHY9k87jD20Li3Y=
205205
</data>
206206
</layer>
207-
<objectgroup id="3" name="Objects" visible="0">
207+
<objectgroup id="3" name="Objects">
208208
<object id="1" name="maggots" type="location" x="435" y="74" width="155" height="99">
209209
<properties>
210210
<property name="spawncount" type="int" value="5"/>

examples/ortho_objects.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use bevy::prelude::*;
2+
use bevy_tiled_prototype::{DebugConfig, Object, TiledMapCenter};
3+
4+
// this example demonstrates debugging objects
5+
6+
const SCALE: f32 = 2.0;
7+
8+
fn main() {
9+
App::build()
10+
.add_plugins(DefaultPlugins)
11+
.add_plugin(bevy_tiled_prototype::TiledMapPlugin)
12+
.add_system(bevy::input::system::exit_on_esc_system.system())
13+
.add_system(toggle_debug.system())
14+
.add_startup_system(setup.system())
15+
.run();
16+
}
17+
18+
fn setup(commands: &mut Commands, asset_server: Res<AssetServer>) {
19+
commands
20+
.spawn(bevy_tiled_prototype::TiledMapComponents {
21+
map_asset: asset_server.load("ortho-map.tmx"),
22+
center: TiledMapCenter(true),
23+
origin: Transform::from_scale(Vec3::new(SCALE, SCALE, 1.0)),
24+
debug_config: DebugConfig {
25+
enabled: true,
26+
material: None,
27+
28+
},
29+
..Default::default()
30+
})
31+
.spawn(Camera2dBundle::default());
32+
}
33+
34+
fn toggle_debug(
35+
keyboard_input: Res<Input<KeyCode>>,
36+
mut query: Query<&mut Visible, With<Object>>,
37+
) {
38+
for mut visible in query.iter_mut() {
39+
if keyboard_input.just_released(KeyCode::Space) {
40+
visible.is_visible = !visible.is_visible;
41+
}
42+
}
43+
}

src/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl Object {
572572
tiled::ObjectShape::Ellipse { width , height } => Some(Vec2::new(width, height)),
573573
tiled::ObjectShape::Polyline { points: _ } |
574574
tiled::ObjectShape::Polygon { points: _ } |
575-
tiled::ObjectShape::Point(_, _) => None,
575+
tiled::ObjectShape::Point(_, _) => Some(Vec2::splat(1.0)),
576576
}
577577
}
578578
}

0 commit comments

Comments
 (0)