跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

godot-adapt-desktop-to-mobile

Expert patterns for porting desktop games to mobile including touch control schemes (virtual joystick, gesture detection), UI scaling for small screens, performance optimization for mobile GPUs, battery life management, and platform-specific features. Use when creating mobile ports or cross-platform mobile builds. Trigger keywords: TouchScreenButton, virtual_joystick, gesture_detector, InputEventScreenTouch, InputEventScreenDrag, mobile_optimization, battery_saving, adaptive_performance, MOBILE_ENABLED.

thedivergentai · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add thedivergentai/GD-Agentic-Skills --skill godot-adapt-desktop-to-mobile

技能说明


name: godot-adapt-desktop-to-mobile description: "Expert patterns for porting desktop games to mobile including touch control schemes (virtual joystick, gesture detection), UI scaling for small screens, performance optimization for mobile GPUs, battery life management, and platform-specific features. Use when creating mobile ports or cross-platform mobile builds. Trigger keywords: TouchScreenButton, virtual_joystick, gesture_detector, InputEventScreenTouch, InputEventScreenDrag, mobile_optimization, battery_saving, adaptive_performance, MOBILE_ENABLED."

Adapt: Desktop to Mobile

Expert guidance for porting desktop games to mobile platforms.

NEVER Do

  • NEVER use mouse position directly — Touch has no "hover" state. Replace mouse_motion with screen_drag and check InputEventScreenTouch.pressed.
  • NEVER keep small UI elements — Apple HIG requires 44pt minimum touch targets. Android Material: 48dp. Scale up buttons 2-3x.
  • NEVER forget finger occlusion — User's finger blocks 50-100px radius. Position critical info ABOVE touch controls, not below.
  • NEVER run at full performance when backgrounded — Mobile OSs kill apps that drain battery in background. Pause physics, reduce FPS to 1-5 when app loses focus.
  • NEVER use desktop-only features — Mouse hover, right-click, keyboard shortcuts, scroll wheel don't exist on mobile. Provide touch alternatives.

Available Scripts

MANDATORY: Read the appropriate script before implementing the corresponding pattern. Do not paste joystick/gesture/UI tutorials inline.

dynamic_joystick_spawner.gd

MANDATORY for move sticks — Joystick appears where the user touches the left half (prefer over fixed-position recipes).

virtual_joystick.gd

Fixed-base stick Control — use when UI art requires a static well; otherwise prefer dynamic_joystick_spawner.

gesture_combo_system.gd

MANDATORY for swipe/pinch — Duration/distance/multi-touch ratio → signals.

mobile_ui_adapter.gd

MANDATORY for Control remaps — Scales/reanchors desktop HUD for thumb reach + density.

resolution_scaler.gd

Adaptive scaling_3d_scale to hold 60FPS while keeping 2D UI sharp.

battery_saver_mode.gd

MANDATORY — NOTIFICATION_APPLICATION_PAUSED → Engine.max_fps = 1 + pause physics.

ui_safe_area_margins.gd

DisplayServer.get_display_safe_area() padding for notches / hole-punch.

touch_camera_pan_zoom.gd

1-finger pan + 2-finger pinch Camera2D.

haptic_feedback_manager.gd

Input.vibrate_handheld + iOS plugin hook pattern.

mobile_shader_fallback.gd

Strip SSS/clearcoat/heavy shading on weak mobile renderers.

on_screen_keyboard_handler.gd

Virtual keyboard occlusion → tween UI up. Use for LineEdit/TextEdit focus — not a substitute for HUD scaling.

mobile_ui_adapter.gd vs on_screen_keyboard_handler

NeedScript
Scale/reanchor HUD, spawn virtual sticks, thumb-reach densitymobile_ui_adapter
OS virtual keyboard covers focused text fieldon_screen_keyboard_handler (often both: adapter for layout, OSK handler for text fields)

offline_save_sync.gd

MANDATORY — Persist on App Pause (WM_CLOSE is unreliable on mobile kill).


Touch Control Schemes

Decision Matrix

GenreRecommended ControlScript
PlatformerVirtual joystick (left) + jump button (right)dynamic_joystick_spawner / virtual_joystick
Top-down shooterDual-stick (move left, aim right)dynamic_joystick_spawner ×2
Turn-basedDirect tap on units/tilesgesture_combo_system (tap)
PuzzleTap, swipe, pinchgesture_combo_system
Card gameDrag-and-dropmobile_ui_adapter + drag Controls
RacingTilt or tap left/rightplatform-mobile / Input sensors

Port Procedure (ordered)

  1. MANDATORY mobile-port-checklist.md — confirm pre-port inventory and gate rows before remapping controls.
  2. Replace hover/right-click/scroll with touch equivalents (decision matrix).
  3. MANDATORY safe-area + mobile_ui_adapter for 44–48dp targets; keep critical HUD above fingers.
  4. Hook battery_saver_mode + offline_save_sync on pause/resume.
  5. Enable resolution_scaler + mobile_shader_fallback until device FPS is stable.
  6. Deep Android/iOS IAP/permissions → godot-platform-mobile (Do NOT Load full platform skill until control/UI/perf gates pass).

Edge Cases (checklist)

  • Multi-touch index conflicts on dual sticks — track event.index per stick
  • OSK covering LineEdit → on_screen_keyboard_handler.gd
  • Background kill without save → offline_save_sync.gd (WM_CLOSE unreliable on mobile)
  • Notch clipping → ui_safe_area_margins.gd
  • Palm touches screen edge — ignore ~50px border taps
  • Desktop test builds: handle both InputEventMouseButton and InputEventScreenTouch

Device testing (before ship)

  • 44–48dp touch targets on real hardware
  • HUD above fingers (50–100px occlusion)
  • Pause drops FPS + saves on background
  • Stable FPS after resolution_scaler.gd + mobile_shader_fallback.gd
  • Portrait + landscape safe areas

Full port recipes → mobile-port-deep.md.

Deep Recipes

MANDATORY when porting beyond the decision matrix: read [mobile-port-deep.md](references/mobile-port-deep

阅读完整来源 ↗