Add UI scaling and window example
parent
a201c2466b
commit
7130672c40
@ -0,0 +1,2 @@
|
||||
* setup CI template in web server running on port 8000
|
||||
* setup mock bevy app running on port 8001 w/ first app running in iframe
|
||||
@ -0,0 +1,34 @@
|
||||
use games::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(BaseGamePlugin { target_resolution: (360.0, 640.0).into(), ..default() })
|
||||
.add_systems(Startup, init_window_info)
|
||||
.add_systems(Update, update_window_info.run_if(any_component_changed::<Window>))
|
||||
.run();
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct WindowInfo;
|
||||
|
||||
fn init_window_info(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
Node {
|
||||
align_self: AlignSelf::Center,
|
||||
justify_self: JustifySelf::Center,
|
||||
..default()
|
||||
},
|
||||
children![(Text::new("Placeholder"), WindowInfo,)],
|
||||
));
|
||||
}
|
||||
|
||||
fn update_window_info(mut text: Single<&mut Text, With<WindowInfo>>, window: Single<&Window>) {
|
||||
text.0 = format!(
|
||||
"Logical: {}x{}\nPhysical: {}x{}\nScale Factor: {}",
|
||||
window.resolution.physical_width(),
|
||||
window.resolution.physical_height(),
|
||||
window.resolution.width(),
|
||||
window.resolution.height(),
|
||||
window.resolution.scale_factor(),
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<body style="margin: 0px;">
|
||||
<script type="module">
|
||||
import init from './bin.js'
|
||||
|
||||
init().catch((error) => {
|
||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,15 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<canvas id="flappy-canvas" ></canvas>
|
||||
|
||||
<body style="margin: 0px;">
|
||||
<script type="module">
|
||||
import init from './bin.js'
|
||||
import init from './bin.js'
|
||||
|
||||
init().catch((error) => {
|
||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
init().catch((error) => {
|
||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue