How to handle different screen sizes. HTML5 Mobile Game Tutorial
indiegamr.com
indiegamr.com
var ratio = Math.min(window.innerWidth/BASE_WIDTH,window.innerHeight/BASE_HEIGHT)
document.body.style.zoom = ratio
or
document.body.style.WebkitTransform='scale('+ratio+')'
Resize the whole board instead of scaling every object.* Half-baked example of what I do (Webkit only as usual)
- when zooming via style.zoom, everything will be zoomed according to a base-width&height, so if the target-device has a different aspect ratio than your base-sizes, you will have to reposition certain objects by hand anyways, also you will have to set the width&height of the canvas manually - as there might be overlapping parts
- when it comes to targeting mobile devices with canvas, you quite often want to use tools like Ludei's cocoonJS or AppMobi's directCanvas, that render html-canvas as a native WebGL-stage on mobile, and css-values like zoom or any other markup will just be ignored on those platforms
- however when you are working with DOM-elements style.zoom can come pretty handy!
I really like your Poker-Demo btw.! Love how the animations are super-smooth! Keep it up! cheers