r/visionosdev • u/MacWinsoft • 5h ago
[Indie Dev] Hold to aim, toggle to fire: implementing UIKit controls for a windowed visionOS arcade game
Hi r/visionosdev! I’m the developer behind Mac Winsoft. Here’s a look at how the on-screen controls are implemented in our windowed arcade game, Paratrooper: Ridge Defense. The attached clip shows the visionOS version.
The interaction is split into two patterns:
- Held input for aiming: the UIKit Left and Right buttons add an action to the held-input set on touchDown, then remove it on touchUpInside, touchUpOutside, or touchCancel. Releasing outside the button is handled as well as releasing inside it.
- Toggled input for firing: the Fire button uses primaryActionTriggered to toggle an autoFire flag, and its label changes between Fire: ON and Fire: OFF. Ammo is a separate button that cycles weapons.
There’s also a lifecycle cleanup path: when the app will resign active, it releases the controls. Pausing goes through the release path too, so held inputs aren’t left active during an interruption.
These are buttons operated through the system’s look-and-pinch interaction. The game is a 2D window, and aiming is driven by the Left/Right buttons rather than the player’s gaze position. The on-screen hint makes the distinction explicit: hold to aim, tap Fire to start or stop firing.
I’d be interested in how other developers handle sustained input in windowed visionOS games. Do you prefer hold or toggle for actions like firing, and what cancellation or interruption cases do you test?
For context, the game has 35 environments and five weapons. It’s available on Vision Pro, Mac, and iPhone/iPad as a $0.99 USD Universal Purchase, with offline play and no ads or in-app purchases. The Apple TV version is awaiting Apple’s review approval. Regional prices vary.
App Store: https://apps.apple.com/app/paratrooper-ridge-defense/id6837016479