最简单的方法是使用基于视口的JavaScript调整画布大小,然后重排内容.
var w = $("#container").width();
var h = $("#container").height();
stage.canvas.width = w;
stage.canvas.height = h;
// Simple "fit-to-screen" scaling
var ratio = contentWidth / contentHeight; // Use the "default" size of the content you have.
var windowRatio = w/h;
var scale = w/contentWidth;
if (windowRatio > ratio) {
scale = h/contentHeight;
}
content.scaleX = content.scaleY = scale;
如果您正在处理移动设备,还需要考虑其他一些事项(它们会自动缩放画布以说明其高DPI).
希望这可以帮助.