首先 我在QpgameActivity.java 新增以下function
public static void changedActivityOrientation (int orientation) {
switch(orientation)
{
case 1: //橫版
Log.d(TAG, "model=ssssss");
mMainApp.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
break;
case 2: //豎板
mMainApp.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
break;
}
}
然後在一個共用的GameUtil.js使用
// 強制轉直
function LandScreen(that, policy) {
if (policy === undefined) {
policy = cc.ResolutionPolicy.FIXED_HEIGHT;
}
var sW = 1920;
var sH = 1080;
if (cc.sys.os === cc.sys.OS_IOS) {
jsb.reflection.callStaticMethod("AppController", "setE");
var height = jsb.reflection.callStaticMethod("AppController", "getheight");
var width = jsb.reflection.callStaticMethod("AppController", "getwidth");
cc.view.setFrameSize(max(height, width), min(height, width));
}else if(cc.sys.os === cc.sys.OS_ANDROID){
cc.log("android LandScreen")
}
cc.view.setDesignResolutionSize(sW, sH, policy);
cc.view.adjustViewPort(true);
cc.view.resizeWithBrowserSize(true);
cc.view.enableRetina(true);
that.setContentSize(cc.size(sW, sH));
that.attr({x: 0, y: 0, width: sW, height: sH});}
在android手機play會一直顯示JS: :0:too much recursion
請問是哪邊出錯了