KineticJS Android的舞台大小 [英] KineticJS android stage size
本文介绍了KineticJS Android的舞台大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Definining KineticJS第一阶段是这样的:
Definining KineticJS Stage I go like this:
var stage = new Kinetic.Stage({
container: 'container',
width: 320,
height: 480
});
所以,宽度和舞台的高度是固定的大小。
如何拉伸它以适合手机屏幕上如果分辨率不同?
So width and height of stage are fixed size. How to stretch it to fit on phone screen if resolution is different?
推荐答案
好了,这的确是一个JavaScript的问题。你想在舞台大小相同的窗口大小。这为我工作在我的Android项目:
Well, this is really a javascript question. You want to make the size of the stage same as the window size. This worked for me on my android project:
var stage = new Kinetic.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight
});
编辑:结果
另外,我建议你添加的jQuery,以及让您可以检查方向更改,那么你可以这样做:
Additionally, I recommend you add jQuery as well so you can check for orientation changes, then you can do something like:
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.
}
或者你可以这样做:
or you could do:
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.
}
这篇关于KineticJS Android的舞台大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文