# Respond to rotation without losing input accuracy

> Keep play readable when a device rotates by recalculating layout and input mapping without treating orientation as a game restart.

- URL: https://oneshotgems.ai/topics/game-orientation-changes
- Category: For game developers
- Type: Guide
- Updated: October 5, 2026

A phone rotation changes the available width and height, but it should not silently invalidate the player’s current input or reset the simulation. Decide whether your game supports both portrait and landscape, then design a clear fallback for the orientation that provides less room. The key is to update presentation and controls as one coordinated change.

## Choose a layout policy

A responsive game can reflow the playfield, letterbox a stable virtual area or show a clear rotate-device prompt. Pick based on the mechanic: a wide lane runner may need horizontal space, while a vertical stacking game may remain readable upright. Avoid stretching the entire scene to fit because that changes object proportions and can make hit areas inconsistent.

Use CSS media queries for layout decisions tied to viewport orientation. Listen for ScreenOrientation changes only when script needs that state; do not rely on the deprecated window orientationchange event. Locking orientation should be a deliberate requirement with a fallback, not a shortcut for an untested layout.

## Rebuild the coordinate mapping

After rotation, measure the current game container and recalculate its presentation transform. Update pointer-to-world coordinate conversion before accepting another action. If a drag is in progress, either preserve it through the new transform or cancel it cleanly; mixing old pointer coordinates with a new canvas size can teleport an object across the scene.

Test rotation before a run, during a drag and with menus open. Verify resize does not start a new session and controls remain reachable. MDN describes ScreenOrientation change events and locking; use them when needed, while allowing device behavior to determine whether a lock succeeds.

## Questions

**Should a browser game force landscape mode?** Only when the game has a strong reason and a clear fallback. A responsive layout or rotate-device prompt may be more appropriate than locking the screen.

**Does rotation always fire a resize event?** Viewport and orientation behavior can differ by browser and device. Test the events your implementation depends on and remeasure the actual game container after a change.

## Follow your curiosity

- [Build Responsive Layouts for Browser Games](https://oneshotgems.ai/topics/responsive-game-layouts): Adapt a game surface to its container without tying simulation state to screen dimensions, and test the layout across changing viewports.
- [Test Browser Game Input Across Devices](https://oneshotgems.ai/topics/testing-game-input-devices): Build a small input test matrix that covers real touch, mouse, keyboard and orientation behavior instead of relying on one desktop session.
- [Design a Mobile Game for Portrait Play](https://oneshotgems.ai/topics/portrait-mobile-game-design): Shape a portrait-first game around one clear playfield, readable status, and changing phone viewports before adding content or landscape support.

## Further reading

- [MDN: Managing screen orientation](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Managing_screen_orientation)
- [MDN: ScreenOrientation change event](https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/change_event)

---
Canonical page: https://oneshotgems.ai/topics/game-orientation-changes
