mirror of https://github.com/axmolengine/axmol.git
Adding rudemntary support for Rotation in Android
This commit is contained in:
parent
bb91f1eb30
commit
f95b802866
|
@ -62,4 +62,7 @@ extern "C" {
|
|||
const char *getCCBDirectoryPath() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void resetCocosApp() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
|||
extern void cleanCacheDirJNI();
|
||||
extern void setDeviceResolutionJNI(const char* res);
|
||||
extern void sendLogMsg(const char* log);
|
||||
extern void resetCocosApp();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,32 @@ 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())
|
||||
|
@ -31,20 +57,25 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
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();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
*/
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnScreenSizeChanged(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
initRotatedView(w,h);
|
||||
}
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxGLSurfaceView_nativeRunCCB(JNIEnv* env, jobject thiz)
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@ public class CocosPlayer extends Cocos2dxActivity{
|
|||
|
||||
public static Activity activity;
|
||||
|
||||
public static void setOrientation(int orient) {
|
||||
activity.setRequestedOrientation(orient);
|
||||
}
|
||||
public static void setOrientation(int orient) {
|
||||
activity.setRequestedOrientation(orient);
|
||||
}
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -94,8 +94,8 @@ public class CocosPlayerSocket {
|
|||
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);
|
||||
CocosPlayer.setOrientation(isPortrait.equalsIgnoreCase("true") ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
//nativeSetOrientation(isPortrait.equalsIgnoreCase("true") ? true : false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue