By the end of this lesson your game will answer a finger instead of an arrow key, and its picture will fit a phone screen without stretching or leaving a border.
You need: the working 2D game from lesson three, and a phone · Time: 8 minutes
The game you built answers the left and right arrow keys. A phone has no arrow keys, and it has no mouse, so nothing the player does reaches the game. The page loads, the game draws, and the player can only watch.
The second difference is smaller and catches people later: a phone has no hover. On a laptop, moving the mouse over a button lights it up before you click. A finger always touches, so any design that depends on seeing a hover state is invisible on a phone.
Touch on the web is handled with pointer events, which report a finger going down, moving and lifting in the same way they report a mouse doing it. That is the part the agent writes for you.
Why?A game that works on a laptop and ignores a phone is not finished, it is unfinished in a way that looks finished. Testing on the machine it was written on hides this completely.
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Three ways to reach a phone, and which one to take first
- The prompt that makes it work with a finger
- Three tests that look the same and prove different things
- Test it the way a player holds it
- Recap