Definining KineticJS阶段我是这样的:KineticJS Android的舞台大小
var stage = new Kinetic.Stage({
container: 'container',
width: 320,
height: 480
});
所以宽度和高度阶段是固定的大小。 如果分辨率不同,如何将其拉伸以适合手机屏幕?
Definining KineticJS阶段我是这样的:KineticJS Android的舞台大小
var stage = new Kinetic.Stage({
container: 'container',
width: 320,
height: 480
});
所以宽度和高度阶段是固定的大小。 如果分辨率不同,如何将其拉伸以适合手机屏幕?
嗯,这真是一个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.
}
不KineticJS大约需要照顾缩放触摸事件? – carobnodrvo 2013-02-20 22:27:07
秤对我来说没问题。在这里,看一下这个例子,你会看到你仍然可以正确拖动,不管比例是多少。 http://cs.neiu.edu/~tsam/planets/index.phtml适用于触摸和桌面 – SoluableNonagon 2013-02-20 22:29:24
感谢这非常帮助我! 但我有另一个问题: 它现在比例完美,但是当我触摸屏时,它会在div标签上闪烁透明的蓝色。 我是usint [this](http://www.html5canvastutorials.com/kineticjs/html5-canvas-desktop-and-mobile-support/)的例子。 – carobnodrvo 2013-02-21 10:56:59
添加JavaScript代码来 – SoluableNonagon 2013-02-20 22:11:04