Skills

Bevy Adapt Mobile To Desktop

Bevy ECS skill for adapting a Bevy mobile game to desktop.

Install

npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-adapt-mobile-to-desktop -g -a claude-code -y
Category
Engineering
Updated
19d ago
License
LGPL-3.0
Context cost
Mediumabout 2,116 tokens
Runs scripts
No, instructions only

What it does

Bevy ECS skill for adapting a Bevy mobile game to desktop. Keywords: Bevy, desktop, mouse, keyboard, adapt, window.

Bevy adapt mobile to desktop

When to use

Load this when a touch-first game gains a window, mouse, and keyboard. Window setup is bevy-platform-desktop.

ECS shape

  • Window: Window, WindowMode, and PrimaryWindow.
  • Input: keyboard, mouse, and gamepad features are named on the crate page and already used by bevy-input-handling.
  • Pointer: CursorOptions on the primary window. CursorGrabMode::None, Confined, or Locked.

Desktop choices

NeedBevy idiom
On-screen buttonsKeyboard and mouse via bevy-input-handling, writing the same intent component.
Wider layoutA wider WindowResolution on the primary Window.
Pointer lockCursorOptions.grab_mode = CursorGrabMode::Locked and visible = false.

Scope

  • Keyboard and mouse write a MoveIntent component. Touch buttons can keep writing that same component.
  • Window mode, resolution, present mode, and cursor grab live on the primary window entity.

Examples

[package]
name = "desktop_port"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.20"

Open a windowed 1920x1080 view and lock the pointer while aiming.

use bevy::window::{
    CursorGrabMode, CursorOptions, MonitorSelection, PresentMode, PrimaryWindow, WindowMode,
    WindowResolution,
};

fn desktop_window(mut windows: Query<&mut Window, With<PrimaryWindow>>) {
    for mut window in &mut windows {
        window.mode = WindowMode::Windowed;
        window.resolution = WindowResolution::new(1920, 1080);
        window.title = "Desktop".to_string();
        window.present_mode = PresentMode::AutoVsync;
    }
}

fn unlock_framerate(mut windows: Query<&mut Window, With<PrimaryWindow>>) {
    for mut window in &mut windows {
        window.present_mode = PresentMode::AutoNoVsync;
    }
}
Read the whole SKILL.md on GitHub

More in Engineering