Bigger games on small phones: what we changed and why
Players told us two things about playing Likable games on a phone. The games looked too small, and in Brick Breaker the whole page slid around while they were dragging the paddle. Both complaints were fair.
This post explains what was causing them, what we changed across all fifteen games, and the two surprises we ran into along the way. Neither surprise showed up until we held a real phone in our hands.
Problem one: a TV-shaped box on a wider screen
Every Likable game is drawn inside a box shaped like a TV screen. That shape is called 16:9, meaning 16 units wide for every 9 units tall. Inside the code, every game is 1280 by 720 points, and the box is scaled up or down to fit whatever screen you have.
The trouble is that many phones, turned sideways, are much wider than a TV. When you scale a 16:9 box up on a screen like that, it touches the top and bottom of the screen first and stops growing. The leftover space on the left and right gets filled with plain color. Those strips are called letterbox bars, and on a phone, where the game is small to begin with, they ate a noticeable slice of the screen.
Problem two: the page thought you were scrolling
Web browsers are built for reading. Drag your finger on a page and the page scrolls. Pull past the top and the page stretches, then springs back, which some people call rubber-banding.
In Brick Breaker you steer the paddle by dragging your finger left and right along the bottom of the screen. Thumbs drift. When a thumb wandered up or off the edge of the game, the browser decided this was no longer a game move but a scroll, and took over. The page slid, and the paddle stopped following your finger right when you needed it.
Fix: the page holds still while you play
We now tell the browser that touches on a game are for the game, not for the page. While a game is on screen, the page no longer scrolls, no longer rubber-bands, and can't be pinch-zoomed by accident. A long press no longer pops up a copy menu or starts selecting text either.
None of this changes how the games play. It just stops the browser from doing its reading-a-web-page tricks in the middle of a round.
Fix: every drag stays attached to the game
The second fix uses a browser feature called pointer capture. In plain words: when your finger first touches the game, the game claims that finger. From then until you lift it, every movement of that finger is reported to the game, even if it slides off the game area onto the bars or past the edge of the screen.
For Brick Breaker, that means the paddle keeps tracking your thumb wherever it wanders. Every other game gets the same treatment, which matters for anything you drag, like slicing in Fruit Slice or aiming in Bubble Blast.
Fix: full screen and sideways
On Android phones, the first time you touch a game it now switches to full screen, which hides the browser's address bar, and locks the screen sideways so it won't flip to upright if you tilt the phone. Browsers only allow a page to go full screen right after you tap something, which is why it waits for that first touch. It only happens for touches, so nothing changes if you're playing with a mouse.
If a phone is held upright, the game is covered by a "Rotate your phone" message with a small animation showing which way to turn it. The game pauses while that message is up, so turning the phone the wrong way never costs you a life or any time on the clock.
Safari on iPhone doesn't let pages go full screen this way. For iPhones and iPads we added a web app manifest, which is a small file that describes the site to the phone: its name, its icon, and that it should open full-screen and sideways. Open the site in Safari, tap Share, then Add to Home Screen, and the new icon opens the games full-screen without Safari's toolbars.
Edge to edge on wide screens
For three games, Chick Flight, Brick Breaker and Fluffy Drop, we went further. On a screen wider than 16:9, these games now fill the whole screen. Instead of black bars at the sides, you see more of the game's world: extra sky in Chick Flight, extra background on both sides of the Brick Breaker wall. On a screen narrower than 16:9, they still add bars, at the top and bottom.
A few details had to change to make that work:
- The score panels moved to the real edges of your screen, so they don't float in the middle of a wide display.
- In Brick Breaker, the wall and the space the ball can bounce in are the same size on every screen. The extra width is scenery, so a wide phone doesn't make the game easier or harder.
- Your finger still lines up with the paddle exactly, because the game works out where your touch lands in the wider picture.
- In Chick Flight, new pillars are created just past the right edge of whatever screen you have, so they slide in from the edge instead of popping into view in the middle of the sky.
Surprise one: the measurement that made everything smaller
A browser can tell a page how big the screen is in two ways. One is the size of the browser window, which developers call the layout viewport. The other is the visual viewport: the part of the page you can actually see right now.
The visual viewport sounds like exactly what you'd want for sizing a game, so we sized every game by it. We checked the result in emulators, which are tools on a computer that pretend to be a phone, and everything looked right.
Then we tried it on a real iPhone, and every game was smaller than before. On the phone, the visible area had Safari's toolbars subtracted from it, so the game was being fitted into a smaller space than the one it actually had. No emulator we used showed this. Only the real phone did.
The fix was to measure both ways and use whichever is larger. Every game now does that, for both width and height.
Surprise two: the pen that shrank by growing
Fluffy Drop gave us the second surprise. It isn't a scrolling world like Chick Flight. It's a pen, a fixed box you drop animals into. When we first made it edge to edge, the pen stayed the same size while more scenery appeared around it. On a wide phone the pen now took up a smaller share of the screen, so it looked smaller. That was the opposite of what players had asked for.
So we kept the game in landscape and widened the pen itself. It now stretches across nearly the full width of the screen, with a small margin at each side. On a wider phone the pen really is wider, with more floor to build on. And if the screen size changes in the middle of a round, for example when the browser's toolbar hides or the game switches to full screen, the animals already in the pen slide along with the walls so none of them ends up outside.
What we learned
Both fixes for the original complaints, keeping the page still and keeping hold of your finger, were straightforward once we understood the cause. The surprises were the part that taught us something. One change made every game smaller on the exact phones it was meant to help, and the other made the pen look smaller by giving it more room. Emulators were fine for checking layouts, but they missed both.
The lesson is simple: test on the real device. If something still looks wrong on yours, tell us at mattsmeeting@gmail.com and include the phone or tablet you're using. The About page has more about the site, and the how-to-play page covers every game's controls.