mirror of https://github.com/axmolengine/axmol.git
Merge pull request #881 from dumganhar/iss1204_initInstance
fixed #1204: Removed CCApplication::initInstance. If users want to custom some features of CCEGLView, e.g. set the design resolution, they should add the following code in "HelloWorld/proj.win32/main.cpp" (on win32) or "HelloWorld/proj.android/jni/helloworld/main.cpp" (on android). CCEGLView::sharedOpenGLView().setDesignResolutionSize(480, 320); You should look into main.cpp files for detail infomations. This commit also update something as follows: 1. Modified some project configuations for win32, we used MultiByte rather than Unicode as CharacterSet for all win32 projects, and removed some unused codes for win32 platform. 2. Made CCEGLView::Create(on win32) as a private function. 3. Updated ExtensionsTest. 4. Updated the format of source files(changed linebreak symbol to UNIX format ('\n'),replaced 'tab' with four spaces).
This commit is contained in:
commit
ec433b46cd
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -85,7 +85,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -17,18 +17,18 @@ typedef struct JniMethodInfo_
|
|||
|
||||
extern "C"
|
||||
{
|
||||
// get env and cache it
|
||||
static JNIEnv* getJNIEnv(void)
|
||||
{
|
||||
// get env and cache it
|
||||
static JNIEnv* getJNIEnv(void)
|
||||
{
|
||||
|
||||
JavaVM* jvm = cocos2d::JniHelper::getJavaVM();
|
||||
JavaVM* jvm = cocos2d::JniHelper::getJavaVM();
|
||||
if (NULL == jvm) {
|
||||
LOGD("Failed to get JNIEnv. JniHelper::getJavaVM() is NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
// get jni environment
|
||||
JNIEnv *env = NULL;
|
||||
// get jni environment
|
||||
jint ret = jvm->GetEnv((void**)&env, JNI_VERSION_1_4);
|
||||
|
||||
switch (ret) {
|
||||
|
@ -59,33 +59,33 @@ extern "C"
|
|||
LOGD("Failed to get the environment using GetEnv()");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get class and make it a global reference, release it at endJni().
|
||||
static jclass getClassID(JNIEnv *pEnv)
|
||||
{
|
||||
jclass ret = pEnv->FindClass(CLASS_NAME);
|
||||
if (! ret)
|
||||
{
|
||||
LOGD("Failed to find class of %s", CLASS_NAME);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *methodName, const char *paramCode)
|
||||
// get class and make it a global reference, release it at endJni().
|
||||
static jclass getClassID(JNIEnv *pEnv)
|
||||
{
|
||||
jmethodID methodID = 0;
|
||||
JNIEnv *pEnv = 0;
|
||||
bool bRet = false;
|
||||
jclass ret = pEnv->FindClass(CLASS_NAME);
|
||||
if (! ret)
|
||||
{
|
||||
LOGD("Failed to find class of %s", CLASS_NAME);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *methodName, const char *paramCode)
|
||||
{
|
||||
jmethodID methodID = 0;
|
||||
JNIEnv *pEnv = 0;
|
||||
bool bRet = false;
|
||||
|
||||
do
|
||||
{
|
||||
pEnv = getJNIEnv();
|
||||
if (! pEnv)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pEnv = getJNIEnv();
|
||||
if (! pEnv)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
jclass classID = getClassID(pEnv);
|
||||
|
||||
|
@ -96,348 +96,348 @@ extern "C"
|
|||
break;
|
||||
}
|
||||
|
||||
methodinfo.classID = classID;
|
||||
methodinfo.env = pEnv;
|
||||
methodinfo.methodID = methodID;
|
||||
methodinfo.classID = classID;
|
||||
methodinfo.env = pEnv;
|
||||
methodinfo.methodID = methodID;
|
||||
|
||||
bRet = true;
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void preloadBackgroundMusicJNI(const char *path)
|
||||
{
|
||||
// void playBackgroundMusic(String,boolean)
|
||||
JniMethodInfo methodInfo;
|
||||
void preloadBackgroundMusicJNI(const char *path)
|
||||
{
|
||||
// void playBackgroundMusic(String,boolean)
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void playBackgroundMusicJNI(const char *path, bool isLoop)
|
||||
{
|
||||
// void playBackgroundMusic(String,boolean)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, isLoop);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void stopBackgroundMusicJNI()
|
||||
{
|
||||
// void stopBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void pauseBackgroundMusicJNI()
|
||||
{
|
||||
// void pauseBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void resumeBackgroundMusicJNI()
|
||||
{
|
||||
// void resumeBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void rewindBackgroundMusicJNI()
|
||||
{
|
||||
// void rewindBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
bool isBackgroundMusicPlayingJNI()
|
||||
{
|
||||
// boolean rewindBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
jboolean ret = false;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
float getBackgroundMusicVolumeJNI()
|
||||
{
|
||||
// float getBackgroundMusicVolume()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
jfloat ret = -1.0;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void setBackgroundMusicVolumeJNI(float volume)
|
||||
{
|
||||
// void setBackgroundMusicVolume()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
unsigned int playEffectJNI(const char* path, bool bLoop)
|
||||
{
|
||||
// int playEffect(String)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
int ret = 0;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;Z)I"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop);
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return (unsigned int)ret;
|
||||
}
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void stopEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void stopEffect(int)
|
||||
void playBackgroundMusicJNI(const char *path, bool isLoop)
|
||||
{
|
||||
// void playBackgroundMusic(String,boolean)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "stopEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, isLoop);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void endJNI()
|
||||
{
|
||||
// void end()
|
||||
void stopBackgroundMusicJNI()
|
||||
{
|
||||
// void stopBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "end", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
float getEffectsVolumeJNI()
|
||||
{
|
||||
// float getEffectsVolume()
|
||||
void pauseBackgroundMusicJNI()
|
||||
{
|
||||
// void pauseBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
jfloat ret = -1.0;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "getEffectsVolume", "()F"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void setEffectsVolumeJNI(float volume)
|
||||
{
|
||||
// void setEffectsVolume(float)
|
||||
JniMethodInfo methodInfo;
|
||||
void resumeBackgroundMusicJNI()
|
||||
{
|
||||
// void resumeBackgroundMusic()
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void preloadEffectJNI(const char *path)
|
||||
{
|
||||
// void preloadEffect(String)
|
||||
void rewindBackgroundMusicJNI()
|
||||
{
|
||||
// void rewindBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "preloadEffect", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void unloadEffectJNI(const char* path)
|
||||
{
|
||||
// void unloadEffect(String)
|
||||
bool isBackgroundMusicPlayingJNI()
|
||||
{
|
||||
// boolean rewindBackgroundMusic()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
jboolean ret = false;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "unloadEffect", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void pauseEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void pauseEffect(int)
|
||||
float getBackgroundMusicVolumeJNI()
|
||||
{
|
||||
// float getBackgroundMusicVolume()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
jfloat ret = -1.0;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void pauseAllEffectsJNI()
|
||||
{
|
||||
// void pauseAllEffects()
|
||||
void setBackgroundMusicVolumeJNI(float volume)
|
||||
{
|
||||
// void setBackgroundMusicVolume()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void resumeEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void resumeEffect(int)
|
||||
unsigned int playEffectJNI(const char* path, bool bLoop)
|
||||
{
|
||||
// int playEffect(String)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
int ret = 0;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;Z)I"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return (unsigned int)ret;
|
||||
}
|
||||
|
||||
void resumeAllEffectsJNI()
|
||||
{
|
||||
// void resumeAllEffects()
|
||||
void stopEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void stopEffect(int)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "stopEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void stopAllEffectsJNI()
|
||||
{
|
||||
// void stopAllEffects()
|
||||
void endJNI()
|
||||
{
|
||||
// void end()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "stopAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if (! getStaticMethodInfo(methodInfo, "end", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
float getEffectsVolumeJNI()
|
||||
{
|
||||
// float getEffectsVolume()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
jfloat ret = -1.0;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "getEffectsVolume", "()F"))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void setEffectsVolumeJNI(float volume)
|
||||
{
|
||||
// void setEffectsVolume(float)
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void preloadEffectJNI(const char *path)
|
||||
{
|
||||
// void preloadEffect(String)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "preloadEffect", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void unloadEffectJNI(const char* path)
|
||||
{
|
||||
// void unloadEffect(String)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "unloadEffect", "(Ljava/lang/String;)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
jstring stringArg = methodInfo.env->NewStringUTF(path);
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
||||
methodInfo.env->DeleteLocalRef(stringArg);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void pauseEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void pauseEffect(int)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void pauseAllEffectsJNI()
|
||||
{
|
||||
// void pauseAllEffects()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "pauseAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void resumeEffectJNI(unsigned int nSoundId)
|
||||
{
|
||||
// void resumeEffect(int)
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeEffect", "(I)V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void resumeAllEffectsJNI()
|
||||
{
|
||||
// void resumeAllEffects()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "resumeAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
|
||||
void stopAllEffectsJNI()
|
||||
{
|
||||
// void stopAllEffects()
|
||||
|
||||
JniMethodInfo methodInfo;
|
||||
|
||||
if (! getStaticMethodInfo(methodInfo, "stopAllEffects", "()V"))
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
||||
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,44 +34,6 @@ AppDelegate::~AppDelegate()
|
|||
//CCScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), CC_WIDTH, CC_HEIGHT));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
// MaxAksenov said it's NOT a very elegant solution. I agree, haha
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -26,9 +26,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->create(480, 320);
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -107,7 +107,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -1,33 +1,40 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
// uncomment below line, open debug console
|
||||
#define USE_WIN32_CONSOLE
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
#ifdef USE_WIN32_CONSOLE
|
||||
AllocConsole();
|
||||
freopen("CONIN$", "r", stdin);
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
#endif
|
||||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
|
||||
int ret = cocos2d::CCApplication::sharedApplication().run();
|
||||
|
||||
#ifdef USE_WIN32_CONSOLE
|
||||
FreeConsole();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
USING_NS_CC;
|
||||
|
||||
// uncomment below line, open debug console
|
||||
#define USE_WIN32_CONSOLE
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
#ifdef USE_WIN32_CONSOLE
|
||||
AllocConsole();
|
||||
freopen("CONIN$", "r", stdin);
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
#endif
|
||||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello Lua");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
|
||||
int ret = CCApplication::sharedApplication().run();
|
||||
|
||||
#ifdef USE_WIN32_CONSOLE
|
||||
FreeConsole();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -11,73 +11,8 @@ AppDelegate::AppDelegate() {
|
|||
|
||||
}
|
||||
|
||||
AppDelegate::~AppDelegate() {
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance() {
|
||||
bool bRet = false;
|
||||
do {
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
//pMainWnd->setDesignResolutionSize(480, 320);
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
// if the resources under '/sdcard" or other writeable path, set it.
|
||||
// warning: the audio source should in assets/
|
||||
// cocos2d::CCFileUtils::setResourcePath("/sdcard");
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
// MaxAksenov said it's NOT a very elegant solution. I agree, haha
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create("cocos2d: Hello World", 480, 320 ,480, 320));
|
||||
|
||||
CCFileUtils::setResourcePath("../Resources/");
|
||||
|
||||
#endif // CC_PLATFORM_LINUX
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||
pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
|
||||
CCFileUtils::setResourcePath("/Res/");
|
||||
|
||||
#endif // CC_PLATFORM_BADA
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(1024, 600));
|
||||
CCFileUtils::setResourcePath("app/native/Resources");
|
||||
#endif // CC_PLATFORM_QNX
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.application;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int helloworld_gl_surfaceview=0x7f050001;
|
||||
public static final int textField=0x7f050000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int helloworld_demo=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
}
|
||||
}
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.application;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int helloworld_gl_surfaceview=0x7f050001;
|
||||
public static final int textField=0x7f050000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int helloworld_demo=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->setDesignResolutionSize(480, 320); Please change it to (320, 480) if you're in portrait mode.
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -97,7 +97,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "../Classes/AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
|
@ -12,6 +14,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
|
||||
return cocos2d::CCApplication::sharedApplication().run();
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello World");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
return CCApplication::sharedApplication().run();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -87,7 +87,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -131,8 +131,8 @@ bool CCDirector::init(void)
|
|||
m_fContentScaleFactor = 1;
|
||||
m_bIsContentScaleSupported = false;
|
||||
|
||||
m_pWatcherFun = NULL;
|
||||
m_pWatcherSender = NULL;
|
||||
m_pWatcherFun = NULL;
|
||||
m_pWatcherSender = NULL;
|
||||
|
||||
// scheduler
|
||||
m_pScheduler = new CCScheduler();
|
||||
|
@ -235,9 +235,9 @@ void CCDirector::drawScene(void)
|
|||
showStats();
|
||||
}
|
||||
|
||||
if (m_pWatcherFun && m_pWatcherSender)
|
||||
{
|
||||
(*m_pWatcherFun)(m_pWatcherSender);
|
||||
if (m_pWatcherFun && m_pWatcherSender)
|
||||
{
|
||||
(*m_pWatcherFun)(m_pWatcherSender);
|
||||
}
|
||||
|
||||
kmGLPopMatrix();
|
||||
|
@ -941,11 +941,11 @@ void CCDisplayLinkDirector::setAnimationInterval(double dValue)
|
|||
}
|
||||
}
|
||||
|
||||
void CCDirector::setWatcherCallbackFun(void *pSender, WatcherCallbackFun fun)
|
||||
{
|
||||
m_pWatcherFun = fun;
|
||||
m_pWatcherSender = pSender;
|
||||
}
|
||||
void CCDirector::setWatcherCallbackFun(void *pSender, WatcherCallbackFun fun)
|
||||
{
|
||||
m_pWatcherFun = fun;
|
||||
m_pWatcherSender = pSender;
|
||||
}
|
||||
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -273,7 +273,7 @@ public:
|
|||
void setContentScaleFactor(CCFloat scaleFactor);
|
||||
CCFloat getContentScaleFactor(void);
|
||||
|
||||
typedef void(*WatcherCallbackFun)(void *pSender);
|
||||
typedef void(*WatcherCallbackFun)(void *pSender);
|
||||
void setWatcherCallbackFun(void *pSender, WatcherCallbackFun fun);
|
||||
|
||||
public:
|
||||
|
@ -391,9 +391,9 @@ protected:
|
|||
|
||||
/* contentScaleFactor could be simulated */
|
||||
bool m_bIsContentScaleSupported;
|
||||
|
||||
WatcherCallbackFun m_pWatcherFun;
|
||||
void *m_pWatcherSender;
|
||||
|
||||
WatcherCallbackFun m_pWatcherFun;
|
||||
void *m_pWatcherSender;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -179,10 +179,10 @@ void CCTimer::update(ccTime dt)
|
|||
{
|
||||
(m_pTarget->*m_pfnSelector)(m_fElapsed);
|
||||
}
|
||||
if (m_nScriptHandler)
|
||||
{
|
||||
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed);
|
||||
}
|
||||
if (m_nScriptHandler)
|
||||
{
|
||||
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed);
|
||||
}
|
||||
m_fElapsed = m_fElapsed - m_fDelay;
|
||||
m_nTimesExecuted+=1;
|
||||
m_bUseDelay = false;
|
||||
|
@ -196,10 +196,10 @@ void CCTimer::update(ccTime dt)
|
|||
{
|
||||
(m_pTarget->*m_pfnSelector)(m_fElapsed);
|
||||
}
|
||||
if (m_nScriptHandler)
|
||||
{
|
||||
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed);
|
||||
}
|
||||
if (m_nScriptHandler)
|
||||
{
|
||||
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed);
|
||||
}
|
||||
m_fElapsed = 0;
|
||||
m_nTimesExecuted += 1;
|
||||
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
#ifndef __CCCONTROL_DEFINE_H__
|
||||
#define __CCCONTROL_DEFINE_H__
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PARENT_CENTER,
|
||||
VERTICAL_TOP,
|
||||
VERTICAL_BOTTOM,
|
||||
HORIZONTAL_LEFT,
|
||||
HORIZONTAL_RIGHT,
|
||||
ABS_WITH_PIXEL,
|
||||
ABS_WITH_PERCENT,
|
||||
REF_PREV_X_INC,
|
||||
REF_PREV_X_DEC,
|
||||
REF_PREV_Y_INC,
|
||||
REF_PREV_Y_DEC,
|
||||
REL_FLOW
|
||||
} LAYOUT_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LAYOUT_TYPE t;
|
||||
union
|
||||
{
|
||||
float pixel_val;
|
||||
float percent_val;
|
||||
} val;
|
||||
} LayoutParamVal;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LayoutParamVal val_x;
|
||||
LayoutParamVal val_y;
|
||||
float padding;
|
||||
bool wrap;
|
||||
} LayoutParam;
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#endif /* __CCCONTROL_DEFINE_H__ */
|
||||
#ifndef __CCCONTROL_DEFINE_H__
|
||||
#define __CCCONTROL_DEFINE_H__
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PARENT_CENTER,
|
||||
VERTICAL_TOP,
|
||||
VERTICAL_BOTTOM,
|
||||
HORIZONTAL_LEFT,
|
||||
HORIZONTAL_RIGHT,
|
||||
ABS_WITH_PIXEL,
|
||||
ABS_WITH_PERCENT,
|
||||
REF_PREV_X_INC,
|
||||
REF_PREV_X_DEC,
|
||||
REF_PREV_Y_INC,
|
||||
REF_PREV_Y_DEC,
|
||||
REL_FLOW
|
||||
} LAYOUT_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LAYOUT_TYPE t;
|
||||
union
|
||||
{
|
||||
float pixel_val;
|
||||
float percent_val;
|
||||
} val;
|
||||
} LayoutParamVal;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LayoutParamVal val_x;
|
||||
LayoutParamVal val_y;
|
||||
float padding;
|
||||
bool wrap;
|
||||
} LayoutParam;
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#endif /* __CCCONTROL_DEFINE_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,188 +1,191 @@
|
|||
#ifndef __CC_LIST_VIEW_H__
|
||||
#define __CC_LIST_VIEW_H__
|
||||
|
||||
#include <time.h>
|
||||
#include "platform.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
//#include "../lua/cocos2dx_support/CCLuaEngine.h"
|
||||
#include "CCListViewCell.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CC_DLL CCRange
|
||||
{
|
||||
public:
|
||||
CCRange()
|
||||
{
|
||||
this->location = 0;
|
||||
this->length = 0;
|
||||
}
|
||||
|
||||
CCRange(unsigned int loc, unsigned int len)
|
||||
{
|
||||
this->location = loc;
|
||||
this->length = len;
|
||||
}
|
||||
|
||||
static unsigned int CCMaxRange(CCRange range)
|
||||
{
|
||||
return (range.location + range.length-1);
|
||||
}
|
||||
|
||||
static bool CCLocationInRange(unsigned int loc, CCRange range)
|
||||
{
|
||||
return (loc - range.location <= range.length);
|
||||
}
|
||||
|
||||
static bool CCEqualRanges(CCRange range1, CCRange range2)
{
return (range1.location == range2.location && range1.length == range2.length);
}
|
||||
|
||||
unsigned int length;
|
||||
unsigned int location;
|
||||
};
|
||||
|
||||
#define CCRangeMake(__min__, __max__) CCRange((__min__), (__max__))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewSlideDirNone,
|
||||
CCListViewSlideDirUp,
|
||||
CCListViewSlideDirDown,
|
||||
CCListViewSlideDirLeft,
|
||||
CCListViewSlideDirRight,
|
||||
} CCListViewSlideDir;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewStateWatting,
|
||||
CCListViewStateTrackingTouch,
|
||||
CCListViewStateEaseOut,
|
||||
CCListViewStateFix,
|
||||
CCListViewStateScroll,
|
||||
} CCListViewState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewModeHorizontal,
|
||||
CCListViewModeVertical,
|
||||
} CCListViewMode;
|
||||
|
||||
typedef struct _CCListViewProtrolData
|
||||
{
|
||||
unsigned int nNumberOfRows;
|
||||
unsigned int nRow;
|
||||
CCListViewCell *cell;
|
||||
} CCListViewProtrolData;
|
||||
|
||||
class CC_DLL CCListViewDelegate
|
||||
{
|
||||
public :
|
||||
CCListViewDelegate(){};
|
||||
virtual ~CCListViewDelegate(){};
|
||||
|
||||
virtual void CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_didScrollToRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
};
|
||||
|
||||
|
||||
class CC_DLL CCListView : public CCLayerColor
|
||||
{
|
||||
public:
|
||||
virtual ~CCListView(void);
|
||||
CCListView(void);
|
||||
|
||||
static CCListView* viewWithMode(CCListViewMode mode);
|
||||
bool initWithMode(CCListViewMode mode);
|
||||
|
||||
void setDelegateName(const char* pszName);
|
||||
void selectCellAtRow(unsigned int nRow);
|
||||
void unselectCellAtRow(unsigned int nRow);
|
||||
void scrollCellToFront(unsigned int nRow, bool bAnimated);
|
||||
void scrollCellToBack(unsigned int nRow, bool bAnimated);
|
||||
void reload(void);
|
||||
void insertCellsAtRow(unsigned int nRow, unsigned int nCount);
|
||||
void deleteCellsAtRow(unsigned int nRow, unsigned int nCount);
|
||||
CCListViewCell *cellAtRow(unsigned int nRow);
|
||||
|
||||
CCListViewSlideDir getSlideDir(CCPoint ptTouchBegan, CCPoint ptTouchEnd);
|
||||
inline CCListViewSlideDir getSlideDir(void) { return m_nSlideDir; }
|
||||
|
||||
inline CCListViewCellSeparatorStyle getSeparatorStyle(void) { return m_nSeparatorStyle; }
|
||||
inline void setSeparatorStyle(CCListViewCellSeparatorStyle style) { m_nSeparatorStyle = style; }
|
||||
inline CCListViewMode getMode(void) { return m_nMode; }
|
||||
|
||||
inline void setListViewParent(CCListView *pParent) { m_pListViewParent = pParent; }
|
||||
inline CCListView *getListViewParent(void) { return m_pListViewParent; }
|
||||
|
||||
inline void setIsEnabled(bool bEnabled) { m_bIsEnabled = bEnabled; }
|
||||
inline bool getIsEnabled(void) { return m_bIsEnabled; }
|
||||
|
||||
// un
|
||||
void setDelegate(const CCListViewDelegate *pDelegate) { m_pDelegate = const_cast<CCListViewDelegate*>(pDelegate);}
|
||||
void finishFix(void);
|
||||
void finishScroll(void);
|
||||
void finishEaseOut(void);
|
||||
|
||||
public:
|
||||
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event);
|
||||
virtual void ccTouchEnded(CCTouch* touch, CCEvent* event);
|
||||
virtual void ccTouchCancelled(CCTouch *touch, CCEvent* event);
|
||||
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event);
|
||||
|
||||
virtual void onEnter(void);
|
||||
virtual void onExit(void);
|
||||
|
||||
virtual void registerWithTouchDispatcher(void);
|
||||
virtual void visit(void);
|
||||
|
||||
protected:
|
||||
void displayVisibleRows(void);
|
||||
CCListViewCell* appendRowToBack(unsigned int nRow);
|
||||
CCListViewCell* appendRowToFront(unsigned int nRow);
|
||||
void fixFirstRow(void);
|
||||
void fixLastRow(void);
|
||||
void easeOutWithDistance(float dis);
|
||||
void clearUnvisibleRows(void);
|
||||
|
||||
int rowForTouch(cocos2d::CCTouch *touch);
|
||||
bool isTouchInside(CCTouch *touch);
|
||||
bool isFullFill(void);
|
||||
|
||||
void stopActionImmediately(void);
|
||||
|
||||
unsigned int triggerNumberOfCells(void);
|
||||
CCListViewCell *triggerCellForRow(unsigned int nRow);
|
||||
void triggerDidClickCellAtRow(unsigned int nRow);
|
||||
void triggerDidScrollToRow(unsigned int nRow);
|
||||
bool isMenuTouch(CCTouch *touch, CCNode *parent);
|
||||
|
||||
private:
|
||||
CCListViewState m_nState;
|
||||
CCListViewMode m_nMode;
|
||||
CCListViewSlideDir m_nSlideDir;
|
||||
CCListViewCellSeparatorStyle m_nSeparatorStyle;
|
||||
unsigned int m_nNumberOfRows;
|
||||
float m_fActionDuration;
|
||||
clock_t m_timeTouchBegan;
|
||||
CCRange m_drawedRows; //所有已绘制的cell
|
||||
CCRange m_visibleRows; //所有可见的cell
|
||||
CCPoint m_ptTouchBegan;
|
||||
CCPoint m_ptTouchEnd;
|
||||
CCPoint m_ptPanelOffset;
|
||||
CCPoint m_ptDestination;
|
||||
std::string m_strDeletegate;
|
||||
CCListViewDelegate* m_pDelegate;
|
||||
CCLayer* m_layerPanel;
|
||||
CCListView* m_pListViewParent;
|
||||
int m_nSelectedRow;
|
||||
int m_nCurrentRow;
|
||||
bool m_bIsEnabled;
|
||||
bool m_bIsOnTouch;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
|
||||
#ifndef __CC_LIST_VIEW_H__
|
||||
#define __CC_LIST_VIEW_H__
|
||||
|
||||
#include <time.h>
|
||||
#include "platform.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
//#include "../lua/cocos2dx_support/CCLuaEngine.h"
|
||||
#include "CCListViewCell.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CC_DLL CCRange
|
||||
{
|
||||
public:
|
||||
CCRange()
|
||||
{
|
||||
this->location = 0;
|
||||
this->length = 0;
|
||||
}
|
||||
|
||||
CCRange(unsigned int loc, unsigned int len)
|
||||
{
|
||||
this->location = loc;
|
||||
this->length = len;
|
||||
}
|
||||
|
||||
static unsigned int CCMaxRange(CCRange range)
|
||||
{
|
||||
return (range.location + range.length-1);
|
||||
}
|
||||
|
||||
static bool CCLocationInRange(unsigned int loc, CCRange range)
|
||||
{
|
||||
return (loc - range.location <= range.length);
|
||||
}
|
||||
|
||||
static bool CCEqualRanges(CCRange range1, CCRange range2)
|
||||
{
|
||||
return (range1.location == range2.location && range1.length == range2.length);
|
||||
}
|
||||
|
||||
unsigned int length;
|
||||
unsigned int location;
|
||||
};
|
||||
|
||||
#define CCRangeMake(__min__, __max__) CCRange((__min__), (__max__))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewSlideDirNone,
|
||||
CCListViewSlideDirUp,
|
||||
CCListViewSlideDirDown,
|
||||
CCListViewSlideDirLeft,
|
||||
CCListViewSlideDirRight,
|
||||
} CCListViewSlideDir;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewStateWatting,
|
||||
CCListViewStateTrackingTouch,
|
||||
CCListViewStateEaseOut,
|
||||
CCListViewStateFix,
|
||||
CCListViewStateScroll,
|
||||
} CCListViewState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCListViewModeHorizontal,
|
||||
CCListViewModeVertical,
|
||||
} CCListViewMode;
|
||||
|
||||
typedef struct _CCListViewProtrolData
|
||||
{
|
||||
unsigned int nNumberOfRows;
|
||||
unsigned int nRow;
|
||||
CCListViewCell *cell;
|
||||
} CCListViewProtrolData;
|
||||
|
||||
class CC_DLL CCListViewDelegate
|
||||
{
|
||||
public :
|
||||
CCListViewDelegate(){};
|
||||
virtual ~CCListViewDelegate(){};
|
||||
|
||||
virtual void CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
virtual void CCListView_didScrollToRow(CCListView *listView, CCListViewProtrolData *data)=0;
|
||||
};
|
||||
|
||||
|
||||
class CC_DLL CCListView : public CCLayerColor
|
||||
{
|
||||
public:
|
||||
virtual ~CCListView(void);
|
||||
CCListView(void);
|
||||
|
||||
static CCListView* viewWithMode(CCListViewMode mode);
|
||||
bool initWithMode(CCListViewMode mode);
|
||||
|
||||
void setDelegateName(const char* pszName);
|
||||
void selectCellAtRow(unsigned int nRow);
|
||||
void unselectCellAtRow(unsigned int nRow);
|
||||
void scrollCellToFront(unsigned int nRow, bool bAnimated);
|
||||
void scrollCellToBack(unsigned int nRow, bool bAnimated);
|
||||
void reload(void);
|
||||
void insertCellsAtRow(unsigned int nRow, unsigned int nCount);
|
||||
void deleteCellsAtRow(unsigned int nRow, unsigned int nCount);
|
||||
CCListViewCell *cellAtRow(unsigned int nRow);
|
||||
|
||||
CCListViewSlideDir getSlideDir(CCPoint ptTouchBegan, CCPoint ptTouchEnd);
|
||||
inline CCListViewSlideDir getSlideDir(void) { return m_nSlideDir; }
|
||||
|
||||
inline CCListViewCellSeparatorStyle getSeparatorStyle(void) { return m_nSeparatorStyle; }
|
||||
inline void setSeparatorStyle(CCListViewCellSeparatorStyle style) { m_nSeparatorStyle = style; }
|
||||
inline CCListViewMode getMode(void) { return m_nMode; }
|
||||
|
||||
inline void setListViewParent(CCListView *pParent) { m_pListViewParent = pParent; }
|
||||
inline CCListView *getListViewParent(void) { return m_pListViewParent; }
|
||||
|
||||
inline void setIsEnabled(bool bEnabled) { m_bIsEnabled = bEnabled; }
|
||||
inline bool getIsEnabled(void) { return m_bIsEnabled; }
|
||||
|
||||
// un
|
||||
void setDelegate(const CCListViewDelegate *pDelegate) { m_pDelegate = const_cast<CCListViewDelegate*>(pDelegate);}
|
||||
void finishFix(void);
|
||||
void finishScroll(void);
|
||||
void finishEaseOut(void);
|
||||
|
||||
public:
|
||||
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event);
|
||||
virtual void ccTouchEnded(CCTouch* touch, CCEvent* event);
|
||||
virtual void ccTouchCancelled(CCTouch *touch, CCEvent* event);
|
||||
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event);
|
||||
|
||||
virtual void onEnter(void);
|
||||
virtual void onExit(void);
|
||||
|
||||
virtual void registerWithTouchDispatcher(void);
|
||||
virtual void visit(void);
|
||||
|
||||
protected:
|
||||
void displayVisibleRows(void);
|
||||
CCListViewCell* appendRowToBack(unsigned int nRow);
|
||||
CCListViewCell* appendRowToFront(unsigned int nRow);
|
||||
void fixFirstRow(void);
|
||||
void fixLastRow(void);
|
||||
void easeOutWithDistance(float dis);
|
||||
void clearUnvisibleRows(void);
|
||||
|
||||
int rowForTouch(cocos2d::CCTouch *touch);
|
||||
bool isTouchInside(CCTouch *touch);
|
||||
bool isFullFill(void);
|
||||
|
||||
void stopActionImmediately(void);
|
||||
|
||||
unsigned int triggerNumberOfCells(void);
|
||||
CCListViewCell *triggerCellForRow(unsigned int nRow);
|
||||
void triggerDidClickCellAtRow(unsigned int nRow);
|
||||
void triggerDidScrollToRow(unsigned int nRow);
|
||||
bool isMenuTouch(CCTouch *touch, CCNode *parent);
|
||||
|
||||
private:
|
||||
CCListViewState m_nState;
|
||||
CCListViewMode m_nMode;
|
||||
CCListViewSlideDir m_nSlideDir;
|
||||
CCListViewCellSeparatorStyle m_nSeparatorStyle;
|
||||
unsigned int m_nNumberOfRows;
|
||||
float m_fActionDuration;
|
||||
clock_t m_timeTouchBegan;
|
||||
CCRange m_drawedRows; //所有已绘制的cell
|
||||
CCRange m_visibleRows; //所有可见的cell
|
||||
CCPoint m_ptTouchBegan;
|
||||
CCPoint m_ptTouchEnd;
|
||||
CCPoint m_ptPanelOffset;
|
||||
CCPoint m_ptDestination;
|
||||
std::string m_strDeletegate;
|
||||
CCListViewDelegate* m_pDelegate;
|
||||
CCLayer* m_layerPanel;
|
||||
CCListView* m_pListViewParent;
|
||||
int m_nSelectedRow;
|
||||
int m_nCurrentRow;
|
||||
bool m_bIsEnabled;
|
||||
bool m_bIsOnTouch;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
|
||||
#endif // __CC_LIST_VIEW_H__
|
|
@ -1,96 +1,96 @@
|
|||
#include "CCListView.h"
|
||||
#include "CCListViewCell.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
const int TOUCHBEGIN = 1;
|
||||
const int TOUCHEND = 2;
|
||||
const int TOUCHMOVING = 3;
|
||||
const int TOUCHCANCELLED= 4;
|
||||
|
||||
|
||||
/******************************************
|
||||
**************Public Functions*************
|
||||
*******************************************/
|
||||
CCListViewCell::CCListViewCell(void)
|
||||
:m_nSeparatorStyle(CCListViewCellSeparatorStyleNone)
|
||||
,m_bIsSelected(false)
|
||||
{
|
||||
setIsTouchEnabled(true);
|
||||
m_selectionColor = ccc4(0, 0, 255, 255);
|
||||
m_separatorLineColor = ccc3(128, 128, 128);
|
||||
}
|
||||
|
||||
CCListViewCell::~CCListViewCell(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCListViewCell *CCListViewCell::node(void)
|
||||
{
|
||||
CCListViewCell *pRet = new CCListViewCell();
|
||||
pRet->initWithColorWidthHeight(ccc4(255, 255, 255, 255), 0, 0);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
void CCListViewCell::selected(void)
|
||||
{
|
||||
m_bIsSelected = true;
|
||||
CCLayerColor::setColor(ccc3(m_selectionColor.r, m_selectionColor.g, m_selectionColor.b));
|
||||
CCLayerColor::setOpacity(m_selectionColor.a);
|
||||
}
|
||||
|
||||
void CCListViewCell::unselected(void)
|
||||
{
|
||||
m_bIsSelected = false;
|
||||
CCLayerColor::setColor(ccc3(m_normalColor.r, m_normalColor.g, m_normalColor.b));
|
||||
CCLayerColor::setOpacity(m_normalColor.a);
|
||||
}
|
||||
|
||||
/******************************************
|
||||
**************Virturl Functions************
|
||||
*******************************************/
|
||||
#include "CCListView.h"
|
||||
#include "CCListViewCell.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
const int TOUCHBEGIN = 1;
|
||||
const int TOUCHEND = 2;
|
||||
const int TOUCHMOVING = 3;
|
||||
const int TOUCHCANCELLED= 4;
|
||||
|
||||
|
||||
/******************************************
|
||||
**************Public Functions*************
|
||||
*******************************************/
|
||||
CCListViewCell::CCListViewCell(void)
|
||||
:m_nSeparatorStyle(CCListViewCellSeparatorStyleNone)
|
||||
,m_bIsSelected(false)
|
||||
{
|
||||
setIsTouchEnabled(true);
|
||||
m_selectionColor = ccc4(0, 0, 255, 255);
|
||||
m_separatorLineColor = ccc3(128, 128, 128);
|
||||
}
|
||||
|
||||
CCListViewCell::~CCListViewCell(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCListViewCell *CCListViewCell::node(void)
|
||||
{
|
||||
CCListViewCell *pRet = new CCListViewCell();
|
||||
pRet->initWithColorWidthHeight(ccc4(255, 255, 255, 255), 0, 0);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
void CCListViewCell::selected(void)
|
||||
{
|
||||
m_bIsSelected = true;
|
||||
CCLayerColor::setColor(ccc3(m_selectionColor.r, m_selectionColor.g, m_selectionColor.b));
|
||||
CCLayerColor::setOpacity(m_selectionColor.a);
|
||||
}
|
||||
|
||||
void CCListViewCell::unselected(void)
|
||||
{
|
||||
m_bIsSelected = false;
|
||||
CCLayerColor::setColor(ccc3(m_normalColor.r, m_normalColor.g, m_normalColor.b));
|
||||
CCLayerColor::setOpacity(m_normalColor.a);
|
||||
}
|
||||
|
||||
/******************************************
|
||||
**************Virturl Functions************
|
||||
*******************************************/
|
||||
bool CCListViewCell::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
{
|
||||
this->m_normalColor = color;
|
||||
return CCLayerColor::initWithColor(color, width, height);
|
||||
}
|
||||
|
||||
void CCListViewCell::draw(void)
|
||||
{
|
||||
CCLayerColor::draw();
|
||||
CCSize size = this->getContentSize();
|
||||
CCListView *owner = this->getOwner();
|
||||
if (CCListViewCellSeparatorStyleSingleLine == m_nSeparatorStyle)
|
||||
{
|
||||
glLineWidth(1.0f);
|
||||
ccDrawColor4B(m_separatorLineColor.r, m_separatorLineColor.g, m_separatorLineColor.b, 255);
|
||||
|
||||
if (CCListViewModeHorizontal == owner->getMode())
|
||||
{
|
||||
ccDrawLine(CCPointMake(size.width, 0), CCPointMake(size.width, size.height));
|
||||
}
|
||||
else if (CCListViewModeVertical == owner->getMode())
|
||||
{
|
||||
ccDrawLine(CCPointMake(0, 0), CCPointMake(size.width, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
this->m_normalColor = color;
|
||||
return CCLayerColor::initWithColor(color, width, height);
|
||||
}
|
||||
|
||||
void CCListViewCell::draw(void)
|
||||
{
|
||||
CCLayerColor::draw();
|
||||
CCSize size = this->getContentSize();
|
||||
CCListView *owner = this->getOwner();
|
||||
if (CCListViewCellSeparatorStyleSingleLine == m_nSeparatorStyle)
|
||||
{
|
||||
glLineWidth(1.0f);
|
||||
ccDrawColor4B(m_separatorLineColor.r, m_separatorLineColor.g, m_separatorLineColor.b, 255);
|
||||
|
||||
if (CCListViewModeHorizontal == owner->getMode())
|
||||
{
|
||||
ccDrawLine(CCPointMake(size.width, 0), CCPointMake(size.width, size.height));
|
||||
}
|
||||
else if (CCListViewModeVertical == owner->getMode())
|
||||
{
|
||||
ccDrawLine(CCPointMake(0, 0), CCPointMake(size.width, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCListViewCell::setColor(ccColor3B var)
|
||||
{
|
||||
m_normalColor.r = var.r;
|
||||
m_normalColor.g = var.g;
|
||||
m_normalColor.b = var.b;
|
||||
CCLayerColor::setColor(var);
|
||||
}
|
||||
|
||||
void CCListViewCell::setOpacity(GLubyte var)
|
||||
{
|
||||
m_normalColor.a = var;
|
||||
CCLayerColor::setOpacity(var);
|
||||
}
|
||||
|
||||
m_normalColor.r = var.r;
|
||||
m_normalColor.g = var.g;
|
||||
m_normalColor.b = var.b;
|
||||
CCLayerColor::setColor(var);
|
||||
}
|
||||
|
||||
void CCListViewCell::setOpacity(GLubyte var)
|
||||
{
|
||||
m_normalColor.a = var;
|
||||
CCLayerColor::setOpacity(var);
|
||||
}
|
||||
|
||||
NS_CC_EXT_END
|
|
@ -1,55 +1,55 @@
|
|||
#ifndef __CC_LIST_VIEW_CELL_H_
|
||||
#define __CC_LIST_VIEW_CELL_H_
|
||||
|
||||
#include "CCControlDefine.h"
|
||||
#include "CCLayer.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CCListView;
|
||||
typedef enum
|
||||
{
|
||||
CCListViewCellSeparatorStyleNone,
|
||||
CCListViewCellSeparatorStyleSingleLine,
|
||||
}CCListViewCellSeparatorStyle;
|
||||
|
||||
class CC_DLL CCListViewCell : public CCLayerColor
|
||||
{
|
||||
public:
|
||||
CCListViewCell(void);
|
||||
virtual ~CCListViewCell(void);
|
||||
|
||||
static CCListViewCell *node(void);
|
||||
|
||||
void selected(void);
|
||||
void unselected(void);
|
||||
|
||||
inline CCListViewCellSeparatorStyle getSeparatorStyle(void) { return m_nSeparatorStyle; }
|
||||
inline void setSeparatorStyle(CCListViewCellSeparatorStyle style) { m_nSeparatorStyle = style; }
|
||||
|
||||
inline ccColor4B getSelectionColor(void) { return m_selectionColor; }
|
||||
inline void setSelectionColor(ccColor4B color) { m_selectionColor = color; }
|
||||
|
||||
inline ccColor3B getSeparatorLineColor(void) { return m_separatorLineColor; }
|
||||
inline void setSeparatorLineColor(ccColor3B color) { m_separatorLineColor = color; }
|
||||
|
||||
public:
|
||||
virtual bool initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||
virtual void draw(void);
|
||||
virtual void setColor(ccColor3B color);
|
||||
virtual void setOpacity(GLubyte var);
|
||||
|
||||
private:
|
||||
inline CCListView *getOwner(void) { return (CCListView*)(this->getParent()->getParent()); }
|
||||
|
||||
private:
|
||||
CCListViewCellSeparatorStyle m_nSeparatorStyle;
|
||||
bool m_bIsSelected;
|
||||
ccColor4B m_selectionColor;
|
||||
ccColor4B m_normalColor;
|
||||
ccColor3B m_separatorLineColor;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#ifndef __CC_LIST_VIEW_CELL_H_
|
||||
#define __CC_LIST_VIEW_CELL_H_
|
||||
|
||||
#include "CCControlDefine.h"
|
||||
#include "CCLayer.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CCListView;
|
||||
typedef enum
|
||||
{
|
||||
CCListViewCellSeparatorStyleNone,
|
||||
CCListViewCellSeparatorStyleSingleLine,
|
||||
}CCListViewCellSeparatorStyle;
|
||||
|
||||
class CC_DLL CCListViewCell : public CCLayerColor
|
||||
{
|
||||
public:
|
||||
CCListViewCell(void);
|
||||
virtual ~CCListViewCell(void);
|
||||
|
||||
static CCListViewCell *node(void);
|
||||
|
||||
void selected(void);
|
||||
void unselected(void);
|
||||
|
||||
inline CCListViewCellSeparatorStyle getSeparatorStyle(void) { return m_nSeparatorStyle; }
|
||||
inline void setSeparatorStyle(CCListViewCellSeparatorStyle style) { m_nSeparatorStyle = style; }
|
||||
|
||||
inline ccColor4B getSelectionColor(void) { return m_selectionColor; }
|
||||
inline void setSelectionColor(ccColor4B color) { m_selectionColor = color; }
|
||||
|
||||
inline ccColor3B getSeparatorLineColor(void) { return m_separatorLineColor; }
|
||||
inline void setSeparatorLineColor(ccColor3B color) { m_separatorLineColor = color; }
|
||||
|
||||
public:
|
||||
virtual bool initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||
virtual void draw(void);
|
||||
virtual void setColor(ccColor3B color);
|
||||
virtual void setOpacity(GLubyte var);
|
||||
|
||||
private:
|
||||
inline CCListView *getOwner(void) { return (CCListView*)(this->getParent()->getParent()); }
|
||||
|
||||
private:
|
||||
CCListViewCellSeparatorStyle m_nSeparatorStyle;
|
||||
bool m_bIsSelected;
|
||||
ccColor4B m_selectionColor;
|
||||
ccColor4B m_normalColor;
|
||||
ccColor3B m_separatorLineColor;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#endif // __CC_LIST_VIEW_CELL_H_
|
|
@ -5,82 +5,82 @@ using namespace std;
|
|||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
#define NUM_PER_PAGE 4
|
||||
#define NUM_PER_PAGE 4
|
||||
|
||||
CCTextureWatcher::CCTextureWatcher()
|
||||
{
|
||||
m_bHide = false;
|
||||
m_nCurrnetPage = 1;
|
||||
m_nTotalPage = 0;
|
||||
m_bFresh = true;
|
||||
m_pTextures = NULL;
|
||||
m_pszString = NULL;
|
||||
m_pLayer = CCLayerColor::layerWithColor(ccc4(128, 128, 128, 128));
|
||||
m_pLayer->retain();
|
||||
m_bHide = false;
|
||||
m_nCurrnetPage = 1;
|
||||
m_nTotalPage = 0;
|
||||
m_bFresh = true;
|
||||
m_pTextures = NULL;
|
||||
m_pszString = NULL;
|
||||
m_pLayer = CCLayerColor::layerWithColor(ccc4(128, 128, 128, 128));
|
||||
m_pLayer->retain();
|
||||
|
||||
// layer
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
size.height *= 0.6;
|
||||
m_pLayer->setContentSize(size);
|
||||
// layer
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
size.height *= 0.6;
|
||||
m_pLayer->setContentSize(size);
|
||||
|
||||
// 屏蔽点击事件的menu
|
||||
//*
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, CCTextAlignmentLeft, "Arial", 12);
|
||||
CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label);
|
||||
menuItem->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem->setPosition(CCPoint(0, 0));
|
||||
|
||||
CCMenu *menu = CCMenu::menuWithItem(menuItem);
|
||||
menu->setAnchorPoint(CCPoint(0, 0));
|
||||
menu->setPosition(CCPoint(0, 0));
|
||||
m_pLayer->addChild(menu);
|
||||
//*/
|
||||
// 屏蔽点击事件的menu
|
||||
//*
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, CCTextAlignmentLeft, "Arial", 12);
|
||||
CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label);
|
||||
menuItem->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem->setPosition(CCPoint(0, 0));
|
||||
|
||||
CCMenu *menu = CCMenu::menuWithItem(menuItem);
|
||||
menu->setAnchorPoint(CCPoint(0, 0));
|
||||
menu->setPosition(CCPoint(0, 0));
|
||||
m_pLayer->addChild(menu);
|
||||
//*/
|
||||
|
||||
// list
|
||||
CCListView *list = CCListView::viewWithMode(CCListViewModeHorizontal);
|
||||
list->setContentSize(size);
|
||||
list->setDelegate(this);
|
||||
list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
|
||||
m_pLayer->addChild(list);
|
||||
m_pList = list;
|
||||
// list
|
||||
CCListView *list = CCListView::viewWithMode(CCListViewModeHorizontal);
|
||||
list->setContentSize(size);
|
||||
list->setDelegate(this);
|
||||
list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
|
||||
m_pLayer->addChild(list);
|
||||
m_pList = list;
|
||||
|
||||
|
||||
// 隐藏按钮
|
||||
CCLabelTTF *labelHide = CCLabelTTF::labelWithString("Hide ", "Arial", 24);
|
||||
labelHide->setColor(ccc3(255, 0, 0));
|
||||
CCMenuItemLabel *menuItem2 = CCMenuItemLabel::itemWithLabel(labelHide, this, menu_selector(CCTextureWatcher::actionHide));
|
||||
menuItem2->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem2->setPosition(CCPoint(0, 0));
|
||||
// 隐藏按钮
|
||||
CCLabelTTF *labelHide = CCLabelTTF::labelWithString("Hide ", "Arial", 24);
|
||||
labelHide->setColor(ccc3(255, 0, 0));
|
||||
CCMenuItemLabel *menuItem2 = CCMenuItemLabel::itemWithLabel(labelHide, this, menu_selector(CCTextureWatcher::actionHide));
|
||||
menuItem2->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem2->setPosition(CCPoint(0, 0));
|
||||
|
||||
CCMenu *menu2 = CCMenu::menuWithItem(menuItem2);
|
||||
menu2->setAnchorPoint(CCPoint(0, 0));
|
||||
menu2->setPosition(CCPoint(size.width - menuItem2->getContentSize().width, 0));
|
||||
CCMenu *menu2 = CCMenu::menuWithItem(menuItem2);
|
||||
menu2->setAnchorPoint(CCPoint(0, 0));
|
||||
menu2->setPosition(CCPoint(size.width - menuItem2->getContentSize().width, 0));
|
||||
|
||||
m_labelHide = labelHide;
|
||||
m_menuHide = menu2;
|
||||
m_menuHide->retain();
|
||||
m_labelHide = labelHide;
|
||||
m_menuHide = menu2;
|
||||
m_menuHide->retain();
|
||||
|
||||
// 更新按钮
|
||||
CCLabelTTF *labelFresh = CCLabelTTF::labelWithString("Fresh", "Arial", 24);
|
||||
labelFresh->setColor(ccc3(255, 0, 0));
|
||||
CCMenuItemLabel *menuItem1 = CCMenuItemLabel::itemWithLabel(labelFresh, this, menu_selector(CCTextureWatcher::actionFresh));
|
||||
menuItem1->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem1->setPosition(CCPoint(0, 0));
|
||||
// 更新按钮
|
||||
CCLabelTTF *labelFresh = CCLabelTTF::labelWithString("Fresh", "Arial", 24);
|
||||
labelFresh->setColor(ccc3(255, 0, 0));
|
||||
CCMenuItemLabel *menuItem1 = CCMenuItemLabel::itemWithLabel(labelFresh, this, menu_selector(CCTextureWatcher::actionFresh));
|
||||
menuItem1->setAnchorPoint(CCPoint(0, 0));
|
||||
menuItem1->setPosition(CCPoint(0, 0));
|
||||
|
||||
CCMenu *menu1 = CCMenu::menuWithItem(menuItem1);
|
||||
menu1->setAnchorPoint(CCPoint(0, 0));
|
||||
menu1->setPosition(CCPoint(size.width - menuItem1->getContentSize().width - menuItem2->getContentSize().width * 1.5, 0));
|
||||
m_pLayer->addChild(menu1);
|
||||
|
||||
// label page
|
||||
m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), CCTextAlignmentCenter, "Arial", 16);
|
||||
m_labelPage->setAnchorPoint(CCPoint(0.5, 0));
|
||||
m_labelPage->setPosition(CCPoint(size.width/2.0, 0));
|
||||
m_pLayer->addChild(m_labelPage, 0);
|
||||
CCMenu *menu1 = CCMenu::menuWithItem(menuItem1);
|
||||
menu1->setAnchorPoint(CCPoint(0, 0));
|
||||
menu1->setPosition(CCPoint(size.width - menuItem1->getContentSize().width - menuItem2->getContentSize().width * 1.5, 0));
|
||||
m_pLayer->addChild(menu1);
|
||||
|
||||
// label page
|
||||
m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), CCTextAlignmentCenter, "Arial", 16);
|
||||
m_labelPage->setAnchorPoint(CCPoint(0.5, 0));
|
||||
m_labelPage->setPosition(CCPoint(size.width/2.0, 0));
|
||||
m_pLayer->addChild(m_labelPage, 0);
|
||||
}
|
||||
CCTextureWatcher::~CCTextureWatcher()
|
||||
{
|
||||
if (m_menuHide)
|
||||
if (m_menuHide)
|
||||
{
|
||||
m_menuHide->removeFromParentAndCleanup(true);
|
||||
m_menuHide->release();
|
||||
|
@ -92,101 +92,101 @@ CCTextureWatcher::~CCTextureWatcher()
|
|||
}
|
||||
|
||||
if (m_pTextures) m_pTextures->release();
|
||||
if (m_pszString) delete []m_pszString;
|
||||
if (m_pszString) delete []m_pszString;
|
||||
}
|
||||
void CCTextureWatcher::actionFresh(CCObject* object)
|
||||
{
|
||||
CCTextureWatcher::sharedTextureWatcher()->fresh();
|
||||
CCTextureWatcher::sharedTextureWatcher()->fresh();
|
||||
}
|
||||
void CCTextureWatcher::actionHide(CCObject *object)
|
||||
{
|
||||
CCTextureWatcher::sharedTextureWatcher()->hide();
|
||||
CCTextureWatcher::sharedTextureWatcher()->hide();
|
||||
}
|
||||
void CCTextureWatcher::fresh()
|
||||
{
|
||||
m_nCurrnetPage = 1;
|
||||
m_bFresh = true;
|
||||
m_nCurrnetPage = 1;
|
||||
m_bFresh = true;
|
||||
}
|
||||
void CCTextureWatcher::hide()
|
||||
{
|
||||
m_bHide = !m_bHide;
|
||||
if (m_bHide)
|
||||
{
|
||||
m_labelHide->setString("Show");
|
||||
m_pLayer->setPosition(CCPoint(0, -m_pLayer->getContentSize().height));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_labelHide->setString("Hide");
|
||||
m_pLayer->setPosition(CCPoint(0, 0));
|
||||
}
|
||||
m_bHide = !m_bHide;
|
||||
if (m_bHide)
|
||||
{
|
||||
m_labelHide->setString("Show");
|
||||
m_pLayer->setPosition(CCPoint(0, -m_pLayer->getContentSize().height));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_labelHide->setString("Hide");
|
||||
m_pLayer->setPosition(CCPoint(0, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CCTextureWatcher::dovisit()
|
||||
{
|
||||
if (m_bFresh)
|
||||
{
|
||||
if (m_pTextures)
|
||||
{
|
||||
m_pTextures->removeAllObjects();
|
||||
m_pTextures->release();
|
||||
}
|
||||
if (m_bFresh)
|
||||
{
|
||||
if (m_pTextures)
|
||||
{
|
||||
m_pTextures->removeAllObjects();
|
||||
m_pTextures->release();
|
||||
}
|
||||
|
||||
CCTextureCache::sharedTextureCache()->removeUnusedTextures();
|
||||
m_pTextures = CCTextureCache::sharedTextureCache()->snapshotTextures();
|
||||
m_nTotalPage = (m_pTextures->count() + NUM_PER_PAGE - 1) / NUM_PER_PAGE;
|
||||
if (m_pTextures->count() > 0)
|
||||
{
|
||||
m_bFresh = false;
|
||||
m_pList->reload();
|
||||
}
|
||||
}
|
||||
CCNode *pParent = m_pLayer->getParent();
|
||||
if (pParent)
|
||||
{
|
||||
if (pParent != CCDirector::sharedDirector()->getRunningScene())
|
||||
{
|
||||
pParent->removeChild(m_pLayer, true);
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
|
||||
m_bFresh = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
|
||||
}
|
||||
CCTextureCache::sharedTextureCache()->removeUnusedTextures();
|
||||
m_pTextures = CCTextureCache::sharedTextureCache()->snapshotTextures();
|
||||
m_nTotalPage = (m_pTextures->count() + NUM_PER_PAGE - 1) / NUM_PER_PAGE;
|
||||
if (m_pTextures->count() > 0)
|
||||
{
|
||||
m_bFresh = false;
|
||||
m_pList->reload();
|
||||
}
|
||||
}
|
||||
CCNode *pParent = m_pLayer->getParent();
|
||||
if (pParent)
|
||||
{
|
||||
if (pParent != CCDirector::sharedDirector()->getRunningScene())
|
||||
{
|
||||
pParent->removeChild(m_pLayer, true);
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
|
||||
m_bFresh = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
|
||||
}
|
||||
|
||||
pParent = m_menuHide->getParent();
|
||||
if (pParent)
|
||||
{
|
||||
if (pParent != CCDirector::sharedDirector()->getRunningScene())
|
||||
{
|
||||
pParent->removeChild(m_menuHide, true);
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
|
||||
}
|
||||
pParent = m_menuHide->getParent();
|
||||
if (pParent)
|
||||
{
|
||||
if (pParent != CCDirector::sharedDirector()->getRunningScene())
|
||||
{
|
||||
pParent->removeChild(m_menuHide, true);
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
|
||||
}
|
||||
}
|
||||
void CCTextureWatcher::visit(void* pSender)
|
||||
{
|
||||
CCTextureWatcher *wartcher = (CCTextureWatcher*)pSender;
|
||||
wartcher->dovisit();
|
||||
CCTextureWatcher *wartcher = (CCTextureWatcher*)pSender;
|
||||
wartcher->dovisit();
|
||||
}
|
||||
|
||||
static CCTextureWatcher *g_sharedTextureWatcher = NULL;
|
||||
|
||||
CCTextureWatcher* CCTextureWatcher::sharedTextureWatcher()
|
||||
{
|
||||
if (!g_sharedTextureWatcher)
|
||||
if (!g_sharedTextureWatcher)
|
||||
{
|
||||
g_sharedTextureWatcher = new CCTextureWatcher();
|
||||
g_sharedTextureWatcher = new CCTextureWatcher();
|
||||
}
|
||||
|
||||
return g_sharedTextureWatcher;
|
||||
return g_sharedTextureWatcher;
|
||||
}
|
||||
|
||||
void CCTextureWatcher::purgeTextureWatcher()
|
||||
|
@ -199,141 +199,141 @@ void CCTextureWatcher::purgeTextureWatcher()
|
|||
|
||||
void CCTextureWatcher::setDisplayWatcher(bool bDisplayWatcher)
|
||||
{
|
||||
m_bDisplayWatcher = bDisplayWatcher;
|
||||
if (m_bDisplayWatcher)
|
||||
{
|
||||
if (m_pszString == NULL)
|
||||
{
|
||||
m_pszString = new char[64];
|
||||
}
|
||||
CCDirector::sharedDirector()->setWatcherCallbackFun(this, &CCTextureWatcher::visit);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->setWatcherCallbackFun(NULL, NULL);
|
||||
m_bDisplayWatcher = bDisplayWatcher;
|
||||
if (m_bDisplayWatcher)
|
||||
{
|
||||
if (m_pszString == NULL)
|
||||
{
|
||||
m_pszString = new char[64];
|
||||
}
|
||||
CCDirector::sharedDirector()->setWatcherCallbackFun(this, &CCTextureWatcher::visit);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCDirector::sharedDirector()->setWatcherCallbackFun(NULL, NULL);
|
||||
purgeTextureWatcher();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCTextureWatcher::CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
data->nNumberOfRows = m_nTotalPage;
|
||||
}
|
||||
|
||||
void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data)
|
||||
void CCTextureWatcher::CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
m_nCurrnetPage = data->nRow + 1;
|
||||
CCListViewCell *cell = CCListViewCell::node();
|
||||
cell->setOpacity(0);
|
||||
cell->setContentSize(m_pList->getContentSize());
|
||||
cell->setSelectionColor(ccc4(0, 0, 0, 0));
|
||||
data->cell = cell;
|
||||
data->nNumberOfRows = m_nTotalPage;
|
||||
}
|
||||
|
||||
CCSize listItemSize = CCSize(m_pList->getContentSize().width / NUM_PER_PAGE, m_pList->getContentSize().height);
|
||||
void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
m_nCurrnetPage = data->nRow + 1;
|
||||
CCListViewCell *cell = CCListViewCell::node();
|
||||
cell->setOpacity(0);
|
||||
cell->setContentSize(m_pList->getContentSize());
|
||||
cell->setSelectionColor(ccc4(0, 0, 0, 0));
|
||||
data->cell = cell;
|
||||
|
||||
CCSize size = CCSize(listItemSize.width * 0.9, listItemSize.height * 0.6);
|
||||
CCSize listItemSize = CCSize(m_pList->getContentSize().width / NUM_PER_PAGE, m_pList->getContentSize().height);
|
||||
|
||||
sprintf(m_pszString, "%d/%d", m_nCurrnetPage, m_nTotalPage);
|
||||
m_labelPage->setString(m_pszString);
|
||||
CCSize size = CCSize(listItemSize.width * 0.9, listItemSize.height * 0.6);
|
||||
|
||||
float offX = 0, offY = 0, offsetX = 0, offsetY = 0;
|
||||
CC_UNUSED_PARAM(offsetY);
|
||||
int nCount = 0;
|
||||
int nStart = (m_nCurrnetPage - 1) * NUM_PER_PAGE;
|
||||
int nEnd = nStart + NUM_PER_PAGE;
|
||||
sprintf(m_pszString, "%d/%d", m_nCurrnetPage, m_nTotalPage);
|
||||
m_labelPage->setString(m_pszString);
|
||||
|
||||
float offX = 0, offY = 0, offsetX = 0, offsetY = 0;
|
||||
CC_UNUSED_PARAM(offsetY);
|
||||
int nCount = 0;
|
||||
int nStart = (m_nCurrnetPage - 1) * NUM_PER_PAGE;
|
||||
int nEnd = nStart + NUM_PER_PAGE;
|
||||
|
||||
CCDictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(m_pTextures, pElement)
|
||||
{
|
||||
if (nCount >= nStart && nCount < nEnd)
|
||||
{
|
||||
string key = pElement->getStrKey();
|
||||
CCTexture2D* textrue = (CCTexture2D*)pElement->getObject();
|
||||
//textrue = m_pTextures->objectForKey(*it);
|
||||
if (textrue)
|
||||
{
|
||||
// 引用数
|
||||
sprintf(m_pszString, "[%d]", textrue->retainCount() - 2);
|
||||
CCLabelTTF *labelCount = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
|
||||
if (textrue->retainCount() - 2 > 0)
|
||||
{
|
||||
labelCount->setColor(ccc3(0, 255, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
labelCount->setColor(ccc3(255, 0, 0));
|
||||
}
|
||||
offX = offsetX + listItemSize.width * 0.5 - labelCount->getContentSize().width * 0.5;
|
||||
offY = (listItemSize.height - size.height) * 0.5 - labelCount->getContentSize().height;
|
||||
labelCount->setPosition(CCPoint(offX, offY));
|
||||
labelCount->setAnchorPoint(CCPoint(0, 0));
|
||||
cell->addChild(labelCount);
|
||||
if (nCount >= nStart && nCount < nEnd)
|
||||
{
|
||||
string key = pElement->getStrKey();
|
||||
CCTexture2D* textrue = (CCTexture2D*)pElement->getObject();
|
||||
//textrue = m_pTextures->objectForKey(*it);
|
||||
if (textrue)
|
||||
{
|
||||
// 引用数
|
||||
sprintf(m_pszString, "[%d]", textrue->retainCount() - 2);
|
||||
CCLabelTTF *labelCount = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
|
||||
if (textrue->retainCount() - 2 > 0)
|
||||
{
|
||||
labelCount->setColor(ccc3(0, 255, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
labelCount->setColor(ccc3(255, 0, 0));
|
||||
}
|
||||
offX = offsetX + listItemSize.width * 0.5 - labelCount->getContentSize().width * 0.5;
|
||||
offY = (listItemSize.height - size.height) * 0.5 - labelCount->getContentSize().height;
|
||||
labelCount->setPosition(CCPoint(offX, offY));
|
||||
labelCount->setAnchorPoint(CCPoint(0, 0));
|
||||
cell->addChild(labelCount);
|
||||
|
||||
// 大小
|
||||
sprintf(m_pszString, "%.0f*%.0f", textrue->getContentSize().width, textrue->getContentSize().height);
|
||||
CCLabelTTF *labelSize = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
|
||||
offX = offsetX + listItemSize.width * 0.5;
|
||||
offY = (listItemSize.height - size.height) * 0.5 + size.height;
|
||||
labelSize->setPosition(CCPoint(offX, offY));
|
||||
labelSize->setAnchorPoint(CCPoint(0.5, 0));
|
||||
cell->addChild(labelSize);
|
||||
// 大小
|
||||
sprintf(m_pszString, "%.0f*%.0f", textrue->getContentSize().width, textrue->getContentSize().height);
|
||||
CCLabelTTF *labelSize = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
|
||||
offX = offsetX + listItemSize.width * 0.5;
|
||||
offY = (listItemSize.height - size.height) * 0.5 + size.height;
|
||||
labelSize->setPosition(CCPoint(offX, offY));
|
||||
labelSize->setAnchorPoint(CCPoint(0.5, 0));
|
||||
cell->addChild(labelSize);
|
||||
|
||||
// 名称
|
||||
int len = key.length();
|
||||
int pos = 0;
|
||||
// 名称
|
||||
int len = key.length();
|
||||
int pos = 0;
|
||||
#if defined(ND_MAC) || defined(ND_IPHONE)
|
||||
pos = key.rfind('/') + 1;
|
||||
pos = key.rfind('/') + 1;
|
||||
#else
|
||||
pos = key.rfind('\\') + 1;
|
||||
int pos2 = key.rfind('/') + 1;
|
||||
pos = pos > pos2 ? pos : pos2;
|
||||
pos = key.rfind('\\') + 1;
|
||||
int pos2 = key.rfind('/') + 1;
|
||||
pos = pos > pos2 ? pos : pos2;
|
||||
#endif
|
||||
string name = key.substr(pos, len - pos);
|
||||
sprintf(m_pszString, "%s", name.c_str());
|
||||
CCSize dimensions = CCSizeMake(listItemSize.width * 0.9, labelSize->getContentSize().height);
|
||||
CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16);
|
||||
offX = offsetX + listItemSize.width * 0.5;
|
||||
offY = offY + labelName->getContentSize().height;
|
||||
labelName->setPosition(CCPoint(offX, offY));
|
||||
labelName->setAnchorPoint(CCPoint(0.5, 0));
|
||||
cell->addChild(labelName);
|
||||
string name = key.substr(pos, len - pos);
|
||||
sprintf(m_pszString, "%s", name.c_str());
|
||||
CCSize dimensions = CCSizeMake(listItemSize.width * 0.9, labelSize->getContentSize().height);
|
||||
CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16);
|
||||
offX = offsetX + listItemSize.width * 0.5;
|
||||
offY = offY + labelName->getContentSize().height;
|
||||
labelName->setPosition(CCPoint(offX, offY));
|
||||
labelName->setAnchorPoint(CCPoint(0.5, 0));
|
||||
cell->addChild(labelName);
|
||||
|
||||
CCSprite *sprite = CCSprite::spriteWithTexture(textrue);
|
||||
sprite->setAnchorPoint(CCPoint(0, 0));
|
||||
CCSprite *sprite = CCSprite::spriteWithTexture(textrue);
|
||||
sprite->setAnchorPoint(CCPoint(0, 0));
|
||||
|
||||
CCSize spriteSize = sprite->getContentSize();
|
||||
float scale;
|
||||
if (spriteSize.width < size.width && spriteSize.height < size.height)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
else if (spriteSize.width * size.height >= spriteSize.height * size.width)
|
||||
{
|
||||
scale = size.width / spriteSize.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = size.height / spriteSize.height;
|
||||
}
|
||||
sprite->setScale(scale);
|
||||
spriteSize.width *= scale;
|
||||
spriteSize.height *= scale;
|
||||
offX = offsetX + (listItemSize.width - spriteSize.width) * 0.5;
|
||||
offY = (listItemSize.height - spriteSize.height) * 0.5;
|
||||
sprite->setPosition(CCPoint(offX, offY));
|
||||
cell->addChild(sprite);
|
||||
offsetX += listItemSize.width;
|
||||
}
|
||||
}
|
||||
++nCount;
|
||||
}
|
||||
}
|
||||
|
||||
void CCTextureWatcher::CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCSize spriteSize = sprite->getContentSize();
|
||||
float scale;
|
||||
if (spriteSize.width < size.width && spriteSize.height < size.height)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
else if (spriteSize.width * size.height >= spriteSize.height * size.width)
|
||||
{
|
||||
scale = size.width / spriteSize.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = size.height / spriteSize.height;
|
||||
}
|
||||
sprite->setScale(scale);
|
||||
spriteSize.width *= scale;
|
||||
spriteSize.height *= scale;
|
||||
offX = offsetX + (listItemSize.width - spriteSize.width) * 0.5;
|
||||
offY = (listItemSize.height - spriteSize.height) * 0.5;
|
||||
sprite->setPosition(CCPoint(offX, offY));
|
||||
cell->addChild(sprite);
|
||||
offsetX += listItemSize.width;
|
||||
}
|
||||
}
|
||||
++nCount;
|
||||
}
|
||||
}
|
||||
|
||||
void CCTextureWatcher::CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CCTextureWatcher::CCListView_didScrollToRow(CCListView *listView, CCListViewProtrolData *data)
|
||||
{
|
||||
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
#ifndef __CCMEMLAYER_H__
|
||||
#define __CCMEMLAYER_H__
|
||||
|
||||
#include "extensions/CCListView/CCListView.h"
|
||||
|
||||
namespace cocos2d { class CCDictionary; }
|
||||
namespace cocos2d { class CCLabelTTF; }
|
||||
namespace cocos2d { class CCMenu; }
|
||||
namespace cocos2d { class CCLayerColor; }
|
||||
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CC_DLL CCTextureWatcher :public CCObject, public CCListViewDelegate
|
||||
{
|
||||
private:
|
||||
CCTextureWatcher();
|
||||
public:
|
||||
virtual ~CCTextureWatcher();
|
||||
|
||||
static CCTextureWatcher* sharedTextureWatcher();
|
||||
static void purgeTextureWatcher();
|
||||
void setDisplayWatcher(bool bDisplayWatcher);
|
||||
void fresh(void);
|
||||
protected:
|
||||
void actionFresh(CCObject* object);
|
||||
void actionHide(CCObject* object);
|
||||
void hide(void);
|
||||
void dovisit(void);
|
||||
static void visit(void* pSender);
|
||||
protected:
|
||||
virtual void CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_didScrollToRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
private:
|
||||
bool m_bDisplayWatcher;
|
||||
bool m_bFresh;
|
||||
bool m_bHide;
|
||||
CCDictionary *m_pTextures;
|
||||
char *m_pszString;
|
||||
int m_nCurrnetPage;
|
||||
int m_nTotalPage;
|
||||
CCLabelTTF *m_labelHide;
|
||||
CCLabelTTF *m_labelPage;
|
||||
CCMenu *m_menuHide;
|
||||
CCLayerColor *m_pLayer;
|
||||
CCListView *m_pList;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#endif
|
||||
#ifndef __CCMEMLAYER_H__
|
||||
#define __CCMEMLAYER_H__
|
||||
|
||||
#include "extensions/CCListView/CCListView.h"
|
||||
|
||||
namespace cocos2d { class CCDictionary; }
|
||||
namespace cocos2d { class CCLabelTTF; }
|
||||
namespace cocos2d { class CCMenu; }
|
||||
namespace cocos2d { class CCLayerColor; }
|
||||
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
class CC_DLL CCTextureWatcher :public CCObject, public CCListViewDelegate
|
||||
{
|
||||
private:
|
||||
CCTextureWatcher();
|
||||
public:
|
||||
virtual ~CCTextureWatcher();
|
||||
|
||||
static CCTextureWatcher* sharedTextureWatcher();
|
||||
static void purgeTextureWatcher();
|
||||
void setDisplayWatcher(bool bDisplayWatcher);
|
||||
void fresh(void);
|
||||
protected:
|
||||
void actionFresh(CCObject* object);
|
||||
void actionHide(CCObject* object);
|
||||
void hide(void);
|
||||
void dovisit(void);
|
||||
static void visit(void* pSender);
|
||||
protected:
|
||||
virtual void CCListView_numberOfCells(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_didClickCellAtRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
virtual void CCListView_didScrollToRow(CCListView *listView, CCListViewProtrolData *data);
|
||||
private:
|
||||
bool m_bDisplayWatcher;
|
||||
bool m_bFresh;
|
||||
bool m_bHide;
|
||||
CCDictionary *m_pTextures;
|
||||
char *m_pszString;
|
||||
int m_nCurrnetPage;
|
||||
int m_nTotalPage;
|
||||
CCLabelTTF *m_labelHide;
|
||||
CCLabelTTF *m_labelPage;
|
||||
CCMenu *m_menuHide;
|
||||
CCLayerColor *m_pLayer;
|
||||
CCListView *m_pList;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,11 +13,6 @@ public:
|
|||
|
||||
virtual ~CCApplicationProtocol() {}
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance() = 0;
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -47,7 +47,7 @@ CCEGLViewProtocol::CCEGLViewProtocol()
|
|||
, m_pDelegate(NULL)
|
||||
, m_fScreenScaleFactor(1.0f)
|
||||
{
|
||||
|
||||
strncpy(m_szViewName, "Cocos2d-x Game", sizeof(m_szViewName));
|
||||
}
|
||||
|
||||
CCEGLViewProtocol::~CCEGLViewProtocol()
|
||||
|
@ -171,6 +171,19 @@ float CCEGLViewProtocol::getMainScreenScale()
|
|||
return -1.0f;
|
||||
}
|
||||
|
||||
void CCEGLViewProtocol::setViewName(const char* pszViewName)
|
||||
{
|
||||
if (pszViewName != NULL && strlen(pszViewName) > 0)
|
||||
{
|
||||
strncpy(m_szViewName, pszViewName, sizeof(m_szViewName));
|
||||
}
|
||||
}
|
||||
|
||||
const char* CCEGLViewProtocol::getViewName()
|
||||
{
|
||||
return m_szViewName;
|
||||
}
|
||||
|
||||
void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
CCSet set;
|
||||
|
|
|
@ -33,7 +33,9 @@ public:
|
|||
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
||||
virtual void setScissorInPoints(float x , float y , float w , float h);
|
||||
virtual float getMainScreenScale();
|
||||
|
||||
virtual void setViewName(const char* pszViewName);
|
||||
const char* getViewName();
|
||||
|
||||
/** handle touch events by default, if you want to custom your handles, please override these functions */
|
||||
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]);
|
||||
|
@ -49,6 +51,7 @@ protected:
|
|||
CCSize m_sSizeInPixel;
|
||||
CCSize m_sSizeInPoint;
|
||||
CCRect m_rcViewPort;
|
||||
char m_szViewName[50];
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -30,11 +30,11 @@ CCApplication::~CCApplication()
|
|||
|
||||
int CCApplication::run()
|
||||
{
|
||||
// Initialize instance and cocos2d.
|
||||
if (! initInstance() || ! applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// Initialize instance and cocos2d.
|
||||
if (! applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle)
|
|||
|
||||
void CCLuaLog(const char * pszFormat)
|
||||
{
|
||||
CCLog(pszFormat);
|
||||
CCLog(pszFormat);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -47,7 +47,7 @@ CCApplication::~CCApplication()
|
|||
|
||||
int CCApplication::run()
|
||||
{
|
||||
if (initInstance() && applicationDidFinishLaunching())
|
||||
if (applicationDidFinishLaunching())
|
||||
{
|
||||
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle)
|
|||
|
||||
void CCLuaLog(const char * pszFormat)
|
||||
{
|
||||
CCLog(pszFormat);
|
||||
CCLog(pszFormat);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -43,7 +43,7 @@ int CCApplication::run()
|
|||
QueryPerformanceCounter(&nLast);
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (! initInstance() || ! applicationDidFinishLaunching())
|
||||
if (!applicationDidFinishLaunching())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -160,17 +160,17 @@ static void PVRFrameEnableControlWindow(bool bEnable)
|
|||
return;
|
||||
}
|
||||
|
||||
const wchar_t * wszValue = L"hide_gui";
|
||||
const wchar_t * wszNewData = (bEnable) ? L"NO" : L"YES";
|
||||
wchar_t wszOldData[256] = {0};
|
||||
DWORD dwSize = sizeof(wszOldData);
|
||||
LSTATUS status = RegQueryValueExW(hKey, wszValue, 0, NULL, (LPBYTE)wszOldData, &dwSize);
|
||||
const char * szValue = "hide_gui";
|
||||
const char * szNewData = (bEnable) ? "NO" : "YES";
|
||||
char szOldData[256] = {0};
|
||||
DWORD dwSize = sizeof(szOldData);
|
||||
LSTATUS status = RegQueryValueEx(hKey, szValue, 0, NULL, (LPBYTE)szOldData, &dwSize);
|
||||
if (ERROR_FILE_NOT_FOUND == status // the key not exist
|
||||
|| (ERROR_SUCCESS == status // or the hide_gui value is exist
|
||||
&& 0 != wcscmp(wszNewData, wszOldData))) // but new data and old data not equal
|
||||
&& 0 != strcmp(szNewData, szOldData))) // but new data and old data not equal
|
||||
{
|
||||
dwSize = sizeof(wchar_t) * (wcslen(wszNewData) + 1);
|
||||
RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize);
|
||||
dwSize = sizeof(wchar_t) * (strlen(szNewData) + 1);
|
||||
RegSetValueEx(hKey, szValue, 0, REG_SZ, (const BYTE *)szNewData, dwSize);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
|
|
@ -51,9 +51,9 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle)
|
|||
MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
|
||||
}
|
||||
|
||||
void CCLuaLog(const char * pszFormat)
|
||||
{
|
||||
CCLog(pszFormat);
|
||||
void CCLuaLog(const char * pszFormat)
|
||||
{
|
||||
CCLog(pszFormat);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -165,8 +165,8 @@ private:
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// impliment CCEGLView
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static CCEGLView * s_pMainWindow;
|
||||
static const WCHAR * kWindowClassName = L"Cocos2dxWin32";
|
||||
static CCEGLView* s_pMainWindow = NULL;
|
||||
static const char* kWindowClassName = "Cocos2dxWin32";
|
||||
|
||||
static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
|
|||
m_hWnd = CreateWindowEx(
|
||||
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
|
||||
kWindowClassName, // Class Name
|
||||
pTitle, // Window Title
|
||||
m_szViewName, // Window Title
|
||||
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style
|
||||
0, 0, // Window Position
|
||||
0, // Window Width
|
||||
|
@ -408,7 +408,6 @@ void CCEGLView::end()
|
|||
}
|
||||
s_pMainWindow = NULL;
|
||||
UnregisterClass(kWindowClassName, GetModuleHandle(NULL));
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
@ -459,7 +458,12 @@ void CCEGLView::resize(int width, int height)
|
|||
m_pEGL->resizeSurface();
|
||||
}
|
||||
|
||||
setFrameSize(width, height);
|
||||
CCEGLViewProtocol::setFrameSize(width, height);
|
||||
}
|
||||
|
||||
void CCEGLView::setFrameSize(float width, float height)
|
||||
{
|
||||
Create((LPCTSTR)m_szViewName, width, height);
|
||||
}
|
||||
|
||||
void CCEGLView::centerWindow()
|
||||
|
@ -509,8 +513,12 @@ void CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
|||
|
||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
||||
{
|
||||
CC_ASSERT(s_pMainWindow);
|
||||
return *s_pMainWindow;
|
||||
static CCEGLView* s_pEglView = NULL;
|
||||
if (s_pEglView == NULL)
|
||||
{
|
||||
s_pEglView = new CCEGLView();
|
||||
}
|
||||
return *s_pEglView;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -37,25 +37,23 @@ class CCEGL;
|
|||
class CC_DLL CCEGLView : public CCEGLViewProtocol
|
||||
{
|
||||
public:
|
||||
|
||||
CCEGLView();
|
||||
virtual ~CCEGLView();
|
||||
|
||||
bool isOpenGLReady();
|
||||
void end();
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
bool canSetContentScaleFactor();
|
||||
void setContentScaleFactor(float contentScaleFactor);
|
||||
|
||||
/* override functions */
|
||||
virtual bool isOpenGLReady();
|
||||
virtual void end();
|
||||
virtual void swapBuffers();
|
||||
virtual bool canSetContentScaleFactor();
|
||||
virtual void setContentScaleFactor(float contentScaleFactor);
|
||||
virtual void setFrameSize(float width, float height);
|
||||
virtual void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
private:
|
||||
virtual bool Create(LPCTSTR pTitle, int w, int h);
|
||||
public:
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
// win32 platform function
|
||||
HWND getHWnd();
|
||||
void resize(int width, int height);
|
||||
|
@ -65,7 +63,6 @@ public:
|
|||
void setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelerometerKeyHook );
|
||||
|
||||
// static function
|
||||
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
|
|
|
@ -60,39 +60,11 @@ public:
|
|||
// release temp font resource
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
{
|
||||
RemoveFontResource(pwszBuffer);
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
RemoveFontResource(m_curFontPath.c_str());
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
wchar_t * utf8ToUtf16(std::string nString)
|
||||
{
|
||||
wchar_t * pwszBuffer = NULL;
|
||||
do
|
||||
{
|
||||
if (nString.size() < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// utf-8 to utf-16
|
||||
int nLen = nString.size();
|
||||
int nBufLen = nLen + 1;
|
||||
pwszBuffer = new wchar_t[nBufLen];
|
||||
CC_BREAK_IF(! pwszBuffer);
|
||||
memset(pwszBuffer,0,nBufLen);
|
||||
nLen = MultiByteToWideChar(CP_UTF8, 0, nString.c_str(), nLen, pwszBuffer, nBufLen);
|
||||
pwszBuffer[nLen] = '\0';
|
||||
} while (0);
|
||||
return pwszBuffer;
|
||||
|
||||
}
|
||||
|
||||
bool setFont(const char * pFontName = NULL, int nSize = 0)
|
||||
{
|
||||
bool bRet = false;
|
||||
|
@ -141,31 +113,20 @@ public:
|
|||
// release old font register
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
if(RemoveFontResource(m_curFontPath.c_str()))
|
||||
{
|
||||
if(RemoveFontResource(pwszBuffer))
|
||||
{
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear());
|
||||
// register temp font
|
||||
if (m_curFontPath.size() > 0)
|
||||
{
|
||||
wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
|
||||
if (pwszBuffer)
|
||||
if(AddFontResource(m_curFontPath.c_str()))
|
||||
{
|
||||
if(AddFontResource(pwszBuffer))
|
||||
{
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
delete [] pwszBuffer;
|
||||
pwszBuffer = NULL;
|
||||
}
|
||||
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hFont = NULL;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -104,7 +104,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -1 +1 @@
|
|||
99a350af562498cb7fcbaec3063f86f9d05889fe
|
||||
215941887bb3ecde65ca64e6e1b5ddaacded6a7c
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -87,7 +87,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,11 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,10 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
|
|
|
@ -22,36 +22,6 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
// OpenGLView is initialized in AppDelegate.mm on ios platform, nothing need to do here.
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// OpenGLView is initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -22,11 +22,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -35,40 +35,6 @@ AppDelegate::~AppDelegate()
|
|||
CCScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), CC_WIDTH, CC_HEIGHT));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
|
||||
// the default setting is to create a fullscreen view
|
||||
// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -16,70 +16,6 @@ AppDelegate::~AppDelegate()
|
|||
// SimpleAudioEngine::end();
|
||||
}
|
||||
|
||||
bool AppDelegate::initInstance()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The tests is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create(TEXT("cocos2d: tests"), 480, 320));
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
// Android doesn't need to do anything.
|
||||
|
||||
#endif // CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationLandscapeLeft);
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||
|
||||
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
|
||||
// The HelloWorld is designed as HVGA.
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd
|
||||
|| ! pMainWnd->Create("cocos2d: tests", 480, 320, 480, 320));
|
||||
|
||||
//set the base resource folder pay attention to add "/"
|
||||
CCFileUtils::setResourcePath("../Resources/");
|
||||
|
||||
#endif // CC_PLATFORM_LINUX
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||
pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
|
||||
CCFileUtils::setResourcePath("/Res/");
|
||||
|
||||
#endif // CC_PLATFORM_BADA
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)
|
||||
CCEGLView * pMainWnd = new CCEGLView();
|
||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(1024, 600));
|
||||
CCFileUtils::setResourcePath("app/native/Resources");
|
||||
#endif // CC_PLATFORM_QNX
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
|
|
|
@ -14,11 +14,6 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement for initialize OpenGL instance, set source path, etc...
|
||||
*/
|
||||
virtual bool initInstance();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -27,9 +27,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
{
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
// view->setDesignResolutionSize(480, 320);
|
||||
CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "AppDelegate.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
|
@ -12,6 +14,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView.setViewName("Hello Tests");
|
||||
eglView.setFrameSize(480, 320);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// eglView.setDesignResolutionSize(480, 320);
|
||||
|
||||
return cocos2d::CCApplication::sharedApplication().run();
|
||||
return CCApplication::sharedApplication().run();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -98,7 +98,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
|
|
@ -5,12 +5,19 @@
|
|||
|
||||
enum
|
||||
{
|
||||
MAX_COUNT = 3,
|
||||
LINE_SPACE = 40,
|
||||
kItemTagBasic = 1000,
|
||||
};
|
||||
|
||||
static const std::string testsName[MAX_COUNT] =
|
||||
enum
|
||||
{
|
||||
TEST_NOTIFICATIONCENTER = 0,
|
||||
TEST_CCCONTROLBUTTON,
|
||||
TEST_TEXTUREWATCHER,
|
||||
TEST_MAX_COUNT
|
||||
};
|
||||
|
||||
static const std::string testsName[TEST_MAX_COUNT] =
|
||||
{
|
||||
"NotificationCenterTest",
|
||||
"CCControlButtonTest",
|
||||
|
@ -32,7 +39,7 @@ void ExtensionsMainLayer::onEnter()
|
|||
pMenu->setPosition( CCPointZero );
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < MAX_COUNT; ++i)
|
||||
for (int i = 0; i < TEST_MAX_COUNT; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::itemWithString(testsName[i].c_str(), this,
|
||||
menu_selector(ExtensionsMainLayer::menuCallback));
|
||||
|
@ -50,17 +57,19 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender)
|
|||
|
||||
switch (nIndex)
|
||||
{
|
||||
case 0:
|
||||
runNotificationCenterTest();
|
||||
case TEST_NOTIFICATIONCENTER:
|
||||
{
|
||||
runNotificationCenterTest();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case TEST_CCCONTROLBUTTON:
|
||||
{
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case TEST_TEXTUREWATCHER:
|
||||
{
|
||||
static bool s_bOpened = false;
|
||||
s_bOpened = !s_bOpened;
|
||||
|
|
|
@ -7,28 +7,32 @@
|
|||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace cocos2d::extension;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
|
||||
view->setFrameWidthAndHeight(w, h);
|
||||
// if you want to run in WVGA with HVGA resource, set it
|
||||
view->create(480, 320);
|
||||
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
|
||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
cocos2d::CCApplication::sharedApplication().run();
|
||||
CCApplication::sharedApplication().run();
|
||||
}
|
||||
else
|
||||
{
|
||||
cocos2d::CCTextureCache::reloadAllTextures();
|
||||
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue