duo-games
Builds games for iPhone Duo, Apple's foldable. The game fills the closed outer display, the open inner display, book pose and tabletop by changing its aspect ratio instead of letterboxing, as Apple's HIG asks; touch controls stay off the fold; and in tabletop the world sits above the fold with the controls below it, like a handheld console. Use when you build or port a SpriteKit, Metal or SwiftUI game, when a game letterboxes, restarts or loses input on fold or unfold, or when you add touch controls or game controller support. Covers SKScene .resizeFill with a camera that keeps the play area in view, one scene or renderer that survives every fold (measured), MTKView drawableSizeWillChange, a UIWindowScene display link that follows the scene to the other display, TouchZones split at the .division reserved region, GameLayout for tabletop, GCController and the simulator's own Gamepad, GCVirtualController and Touch Controller placement, orientation locks the inner display ignores, and two-
Kimeur · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Kimeur/duology --skill duo-games技能说明
name: duo-games description: "Builds games for iPhone Duo, Apple's foldable. The game fills the closed outer display, the open inner display, book pose and tabletop by changing its aspect ratio instead of letterboxing, as Apple's HIG asks; touch controls stay off the fold; and in tabletop the world sits above the fold with the controls below it, like a handheld console. Use when you build or port a SpriteKit, Metal or SwiftUI game, when a game letterboxes, restarts or loses input on fold or unfold, or when you add touch controls or game controller support. Covers SKScene .resizeFill with a camera that keeps the play area in view, one scene or renderer that survives every fold (measured), MTKView drawableSizeWillChange, a UIWindowScene display link that follows the scene to the other display, TouchZones split at the .division reserved region, GameLayout for tabletop, GCController and the simulator's own Gamepad, GCVirtualController and Touch Controller placement, orientation locks the inner display ignores, and two-player games." metadata: verified: "Xcode 27.1 (27A9275), iOS 27.1 simulator, device: no" sources: "https://github.com/Kimeur/duology/blob/main/reference/sources.md"
duo-games
A game on iPhone Duo resizes every time someone opens, closes, rotates or folds the phone, often in the middle of play. This skill keeps the game running through all of it, fills every pose, keeps thumbs off the fold, and turns the bottom half into a controller when the phone sits on a table.
Load neighbours when the task needs them: duo-shared-screen and recipe-two-player-game (two people on one phone), duo-postures (every pose, and hinge effects), duo-layout (reserved regions in depth), duo-continuity (state through a fold), duo-ergonomics (thumb reach).
"Book" and "tabletop" are Duology's words for Apple's "partially folded, like a book" and "seated on a table like a laptop". No API reports them. Labels: measured means we ran it in a probe app on the iPhone Duo simulator (Xcode 27.1, iOS 27.1, 20 Oct 2026); logs in references/measurements.md. Unverified means we could not confirm it. Everything else links to Apple.
Rules
- Fill the screen in every pose. Change the aspect ratio: show more or less of the world. Letterbox only when you can't avoid it, and then put artwork in the bars (HIG: iPhone Duo).
- Keep text and controls the same size in every pose. Size them in points, outside the world, not in world units that a camera scales (HIG: iPhone Duo).
- One game per window, owned above every layout switch. A fold resizes the scene or the drawable. It never makes a new scene, renderer or game state.
- Resize, don't restart. Size callbacks only recompute what depends on size: the camera, the projection, size-matched textures.
- Nothing touchable in the fold. Movement on the leading side, actions on the trailing side, and the whole
.divisionframe, margins included, belongs to neither, flat or folded (talk 111466). - Tabletop: the world in the top region, the controls in the bottom region, and the same controls as every other pose. Apple suggests this split for media on a table; it fits games too (talk 111466).
- Handle tall and wide in every build. You may lock the orientation, but the inner display ignores the lock (talk 111461).
- Touch always works. A game controller is an extra. Hide touch controls only after the player uses a controller (HIG: Game controls).
- Pause on the scene phase, never on a fold. Folding is part of play. Set the scene's own
isPaused:SpriteView(isPaused:)didn't resume the game (measured). - No hinge as a game input unless the player turns it on and an on-screen control does the same job (
duo-postures).
What the game gets in each pose
Measured with the code below: the world ignores the safe area, the controls stay inside it.
| Pose | Window | Scene (world) | Touch controls | .division seen by the controls |
|---|---|---|---|---|
| Closed | 466 × 678 pt | 466 × 678 pt | 382 × 644 pt (84 pt trailing and 34 pt bottom inset) | none |
| Open, flat, held wide | 951 × 669 pt | 951 × 669 pt | 951 × 635 pt | inactive, 40 × 669 pt at x = 455.5 |
| Book | 951 × 669 pt | 951 × 669 pt | 951 × 635 pt | active, same frame |
| Tabletop | 669 × 951 pt | 669 × 455.7 pt, above the fold | 669 × 421.5 pt, below the fold | none: the fold lies outside the controls |
- The fold's frame runs from x = 455.5 to 495.5. That is centred in a full-width 951 pt game, but not in a view that a vertical bar narrows: in an 867 pt view the middle is 22 pt left of the fold (measured in
duo-reading). Split at the fold frame, never atwidth / 2. - Open, held tall, and Split View were not measured with this game. Plan for any size.
1. Fill the screen: resize the scene, move the camera
.resizeFill makes the scene exactly the size of its view (resizeFill). A camera then scales so the play area always fits; spare room shows more world. Every pose we measured is less wide than the 16:10 play area below, so it fills the width and the spare room shows above and below it: a lot on the closed phone held upright, little in book and tabletop (derived from the measured sizes).
import SpriteKit
/// What the touch controls and a game controller write, and the scene reads
阅读完整来源 ↗