嗯,这确实是一个 javascript 问题。您想让舞台的大小与窗口大小相同。这对我的 android 项目有用:
var stage = new Kinetic.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight
});
编辑:
此外,我建议您也添加 jQuery,以便检查方向更改,然后您可以执行以下操作:
window.onresize = function(event) { //this function will resize your stage to the size of your window
stage.setWidth(window.innerWidth);
stage.setHeight(window.innerHeight);
stage.draw(); //redraw the stage, not sure if really needed, but good to have.
}
或者你可以这样做:
window.onresize = function(event) {
stage.setScale(x,y); //set x, y scale values when the orientation changes
stage.draw(); //redraw the stage, not sure if really needed, but good to have.
}