Split a game across the fold: game on one side, controls on the other #1
erkamyaman
started this conversation in
Show and tell
Replies: 2 comments
|
cool, I will give it a try and come back |
0 replies
|
Update: as of 8.1.0 you don't need JavaScript for this at all.
So the split is plain CSS: /* fold runs down the middle: game left, controls right */
.fold-vertical .game { width: var(--fold-left); height: 100%; }
.fold-vertical .controls { left: calc(var(--fold-left) + var(--fold-width)); right: 0; height: 100%; }
/* fold runs across (or a Galaxy Z Flip): game on top, controls below */
.fold-horizontal .game { width: 100%; height: var(--fold-top); }
.fold-horizontal .controls { top: calc(var(--fold-top) + var(--fold-height)); bottom: 0; }
/* no fold: your normal single-screen layout */ |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A developer asked on Reddit whether the plugin could run their three.js game with the gameplay on one half of a foldable and a d-pad on the other, whether the phone is fully open or half-folded. It can, and here's how.
Screen.Recording.2026-09-19.at.22.48.40.mov
How it works ( Roughly )
Even when the phone is fully open,
getFoldState()tells you where the fold is (hingeBounds) and which way it runs (hingeOrientation). Split your layout along that line and update it whenever the phone folds, unfolds or rotates:All reactions