2010-11-03 11:01:17 +08:00
|
|
|
#include "CCXApplication_android.h"
|
|
|
|
#include "CCXUIImage_android.h"
|
|
|
|
#include "CCXEGLView_android.h"
|
|
|
|
#include "CCDirector.h"
|
2011-01-22 15:10:18 +08:00
|
|
|
#include "Cocos2dJni.h"
|
2010-11-03 11:01:17 +08:00
|
|
|
|
|
|
|
#include <GLES/glext.h>
|
2011-01-22 15:10:18 +08:00
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#define LOG_TAG "Application android"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
2010-11-03 11:01:17 +08:00
|
|
|
|
|
|
|
namespace cocos2d {
|
|
|
|
static CCXApplication *s_pApplication;
|
|
|
|
|
|
|
|
CCXApplication::CCXApplication()
|
|
|
|
{
|
|
|
|
s_pApplication = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCXApplication::~CCXApplication()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ccDeviceOrientation CCXApplication::setDeviceOrientation(ccDeviceOrientation eOritation)
|
|
|
|
{
|
|
|
|
return eOritation;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGRect CCXApplication::statusBarFrame()
|
|
|
|
{
|
|
|
|
CGRect rc;
|
|
|
|
return rc;
|
|
|
|
}
|
2010-11-19 14:57:58 +08:00
|
|
|
|
|
|
|
void CCXApplication::Run()
|
|
|
|
{
|
|
|
|
applicationDidFinishLaunching();
|
|
|
|
}
|
2010-11-03 11:01:17 +08:00
|
|
|
|
2011-01-19 22:29:57 +08:00
|
|
|
void CCXApplication::setAnimationInterval(double interval)
|
|
|
|
{
|
2011-01-22 15:10:18 +08:00
|
|
|
jmethodID ret = 0;
|
|
|
|
JNIEnv *env = 0;
|
|
|
|
jclass classOfCocos2dxRenderer = 0;
|
|
|
|
|
|
|
|
// get jni environment and java class for Cocos2dxActivity
|
|
|
|
if (gJavaVM->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK)
|
|
|
|
{
|
|
|
|
LOGD("Failed to get the environment using GetEnv()");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gJavaVM->AttachCurrentThread(&env, 0) < 0)
|
|
|
|
{
|
|
|
|
LOGD("Failed to get the environment using AttachCurrentThread()");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
classOfCocos2dxRenderer = env->FindClass("org/cocos2dx/lib/Cocos2dxRenderer");
|
|
|
|
if (! classOfCocos2dxRenderer)
|
|
|
|
{
|
|
|
|
LOGD("Failed to find class of org/cocos2dx/lib/Cocos2dxRenderer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env != 0 && classOfCocos2dxRenderer != 0)
|
|
|
|
{
|
|
|
|
ret = env->GetStaticMethodID(classOfCocos2dxRenderer, "setAnimationInterval", "(D)V");
|
|
|
|
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
|
|
|
env->CallStaticVoidMethod(classOfCocos2dxRenderer, ret, interval);
|
|
|
|
}
|
|
|
|
}
|
2011-01-19 22:29:57 +08:00
|
|
|
}
|
|
|
|
|
2010-11-03 11:01:17 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/// Implement static class member
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2010-11-19 14:57:58 +08:00
|
|
|
CCXApplication * CCXApplication::sharedApplication()
|
2010-11-03 11:01:17 +08:00
|
|
|
{
|
|
|
|
return s_pApplication;
|
|
|
|
}
|
|
|
|
}
|