2011-03-01 19:53:39 +08:00
|
|
|
#include "AppDelegate.h"
|
2010-12-18 18:23:31 +08:00
|
|
|
#include "cocos2d.h"
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
2011-02-24 19:42:45 +08:00
|
|
|
#define LOG_TAG "main"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
|
|
|
|
2010-12-18 18:23:31 +08:00
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
#define IMG_PATH "assets"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
|
|
|
|
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
|
|
|
{
|
2011-01-10 17:54:44 +08:00
|
|
|
if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
|
|
|
|
{
|
2011-03-08 13:49:58 +08:00
|
|
|
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
|
2011-01-10 17:54:44 +08:00
|
|
|
view->setFrameWitdAndHeight(w, h);
|
2011-02-26 15:52:57 +08:00
|
|
|
// if you want to run in WVGA with HVGA resource, set it
|
|
|
|
// view->create(320, 480);
|
2011-01-10 17:54:44 +08:00
|
|
|
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
|
2011-01-07 16:29:06 +08:00
|
|
|
|
2011-01-10 17:54:44 +08:00
|
|
|
CCFileUtils::setRelativePath(IMG_PATH);
|
|
|
|
|
2011-03-01 19:53:39 +08:00
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
2011-03-08 13:49:58 +08:00
|
|
|
cocos2d::CCApplication::sharedApplication().run();
|
2011-01-10 17:54:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cocos2d::CCTexture2D::reloadAllTextures();
|
|
|
|
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
|
|
|
|
}
|
2010-12-18 18:23:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|