Menu

A Practical Checklist for Mobile Browser Games Built With HTML5
📰

A Practical Checklist for Mobile Browser Games Built With HTML5

DEV Community: html·Instant Games·6 days ago
#4UqjEdsD
#devto2#devto#dev#canvas#games
Long article (697 words) — no AI summary yet.
Reading 0:00
15s threshold

Making an HTML5 game run on a desktop is easy. Making it feel good on a phone, in a mobile browser, with no install, is where most of the work hides. This is the checklist I use for the browser games on InstantGames.in, which all run on phone, tablet and desktop.

1. Touch input, done properly

Use Pointer Events where you can. They unify mouse, touch and pen, and give each finger an id, which is what makes multi-touch work.

// simplified sketch const pointers = new Map ( ) ;

canvas . addEventListener ( "pointerdown" , e => pointers . set ( e . pointerId , [ { x : e . offsetX , y : e . offsetY } ] ) ) ; canvas . addEventListener ( "pointermove" , e => pointers . get ( e . pointerId ) ? . push ( { x : e . offsetX , y : e . offsetY } ) ) ; canvas . addEventListener ( "pointerup" , e => pointers . delete ( e . pointerId ) ) ; canvas . style .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.