我成功地将我的KineticJS游戏嵌入到CocoonJS中,但缩放画布的问题还未解决。我的画布大小为1024x768,在iPad 2上效果很好。但是在iPad 4上,由于Retina屏幕的缘故,游戏只占据了屏幕的1/4。
CocoonJS对此缩放问题给出了以下说明:
CocoonJS automatically scales your main canvas to fill the whole screen while you still
continue working on your application coordinates. There are 3 different ways to specify how
the scaling should be done:
idtkScale
'ScaleToFill' // Default
'ScaleAspectFit'
'ScaleAspectFill'
canvas.style.cssText="idtkscale:SCALE_TYPE;"; // The SCALE_TYPE can be any of
the ones listed above.
我尝试添加了这个:
layer.getCanvas()._canvas.style.cssText='idtkScale:ScaleAspectFit;';
但是它没有起作用。有什么想法可以让KineticJS创建的画布在CocoonJS中进行缩放吗?