
Bevy Adapt Desktop To Mobile
Bevy ECS skill for adapting a Bevy desktop game to mobile.
Install
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-adapt-desktop-to-mobile -g -a claude-code -y- Repository
- thedivergentai/Game-Dev-Agentic-Skills917
- Category
- Design
- Updated
- 19d ago
- License
- LGPL-3.0
- Context cost
- Mediumabout 1,741 tokens
- Runs scripts
- No, instructions only
What it does
Bevy ECS skill for adapting a Bevy desktop game to mobile. Keywords: Bevy, mobile, touch, UI, adapt.
Bevy adapt desktop to mobile
When to use
Load this when a desktop window game must accept touch and a smaller layout. Platform features are on bevy-platform-mobile.
ECS shape
- Input:
Toucheslists active contacts. Action mapping lives on bevy-input-handling. - UI: enlarge
Nodehit targets and pad the root with a safe-insetResource.WindowResolutionsets the logical size and an optional scale-factor override.WindowScaleFactorChangedreports a live dpi change. - Textures: ASTC is a compressed texture format for mobile GPUs. Upload still goes through
Assets<Image>.
fn configure_window(mut windows: Query<&mut Window>) {
let Ok(mut window) = windows.single_mut() else {
return;
};
window.resolution.set(720.0, 1280.0);
window.resolution.set_scale_factor_override(Some(2.0));
}
#[derive(Resource, Default)]
struct LastTouch(Option<Vec2>);
fn track_touch(touches: Res<Touches>, mut last: ResMut<LastTouch>) {
last.0 = touches.iter().next().map(|touch| touch.position());
}
#[derive(Component)]
struct TouchTarget;
#[derive(Component)]
struct HudRoot;
#[derive(Resource)]
struct SafeInsets {
top: f32,
bottom: f32,
}
fn enlarge_targets(mut nodes: Query<&mut Node, With<TouchTarget>>) {
for mut node in &mut nodes {
node.min_width = Val::Px(88.0);
node.min_height = Val::Px(88.0);
}
}
fn pad_hud(insets: Res<SafeInsets>, mut roots: Query<&mut Node, With<HudRoot>>) {
for mut node in &mut roots {
node.padding = UiRect {
top: Val::Px(insets.top),
bottom: Val::Px(insets.bottom),
left: Val::Px(12.0),
right: Val::Px(12.0),
};
}
}
use bevy::window::WindowScaleFactorChanged;


