Removing onSurfaceChange update since it was being executed after ccb_run. This resulted in frame size being changed after game was running (bug)

This commit is contained in:
Rohan Kuruvilla 2013-04-25 18:21:35 -07:00
parent 188f0354f3
commit 8a59680175
2 changed files with 16 additions and 33 deletions

View File

@ -21,32 +21,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
return JNI_VERSION_1_4;
}
static void initRotatedView(jint w, jint h) {
if (!CCDirector::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
bool isPortrait = (w < h) ? true: false;
handle_set_orient(isPortrait);
}
}
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
@ -74,18 +48,17 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnScreenSizeChanged(JNIEnv* env, jobject thiz, jint w, jint h)
{
initRotatedView(w,h);
// handle_set_orient(w, h);
}
void Java_org_cocos2dx_lib_Cocos2dxGLSurfaceView_nativeRunCCB(JNIEnv* env, jobject thiz)
{
LOGD("INSIDE JNI RUN CALL");
handle_ccb_run();
}
void Java_org_cocos2dx_cocosplayer_CocosPlayerSocket_nativeRunCCB(JNIEnv* env, jobject thiz)
{
LOGD("INSIDE JNI RUN CALL");
LOGD("INSIDE JNI RUN CALL %d %d", gettid(), getpid());
handle_ccb_run();
}
@ -112,6 +85,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
void Java_org_cocos2dx_cocosplayer_CocosPlayerSocket_nativeSetOrientation(JNIEnv* env, jobject thiz, jboolean isPortrait)
{
LOGD("INSIDE SET ORIENTATION CALL");
handle_set_orient((bool)isPortrait);
}
}

View File

@ -93,10 +93,19 @@ public class CocosPlayerSocket {
private static native void nativeSetOrientation(boolean isPortrait);
private static native void nativeRunScript(final String script);
private static void setOrientation(String isPortrait) {
CocosPlayer.setOrientation(isPortrait.equalsIgnoreCase("true") ?
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//nativeSetOrientation(isPortrait.equalsIgnoreCase("true") ? true : false);
private static void setOrientation(final String isPortrait) {
Cocos2dxGLSurfaceView.getInstance().setPreserveEGLContextOnPause(true);
Cocos2dxGLSurfaceView.getInstance().queueEvent(new Runnable() {
@Override
public void run() {
CocosPlayer.setOrientation(isPortrait.equalsIgnoreCase("true") ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
nativeSetOrientation(isPortrait.equalsIgnoreCase("true") ? true
: false);
}
});
}
private void switchCmd(NSDictionary data) {