fixed #233 now don't call preMainLoop when application enter background, test ok on uphone device.

fixed a CCXAppWiz.uphone bug, create a empty file named xxxxx_str_str.h when build.

Signed-off-by: yangws <yangws@cocos2d-x.org>
This commit is contained in:
yangws 2010-12-03 15:27:55 +08:00
parent 4df7cbcc40
commit 96115bc26e
7 changed files with 26 additions and 21 deletions

View File

@ -67,7 +67,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() void AppDelegate::applicationDidEnterBackground()
{ {
CCDirector::sharedDirector()->stopAnimation(); CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause // if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
@ -76,7 +76,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again // this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() void AppDelegate::applicationWillEnterForeground()
{ {
CCDirector::sharedDirector()->startAnimation(); CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here // if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();

View File

@ -187,6 +187,10 @@ private:
EGLContext m_eglContext; EGLContext m_eglContext;
}; };
//////////////////////////////////////////////////////////////////////////
// impliment CCXEGLView
//////////////////////////////////////////////////////////////////////////
CCXEGLView::CCXEGLView(TApplication * pApp) CCXEGLView::CCXEGLView(TApplication * pApp)
: TWindow(pApp) : TWindow(pApp)
, m_bCaptured(false) , m_bCaptured(false)
@ -222,6 +226,10 @@ Boolean CCXEGLView::EventHandler(TApplication * pApp, EventType * pEvent)
break; break;
case EVENT_WinPaint: case EVENT_WinPaint:
// prevent back light turn off
CfgRefreshScreenAutoOffDelaySeconds();
// draw
CCDirector::sharedDirector()->preMainLoop(); CCDirector::sharedDirector()->preMainLoop();
bHandled = TRUE; bHandled = TRUE;
break; break;

View File

@ -358,7 +358,7 @@ function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile) {
wizard.RenderTemplate(strTemplate, strFile, bCopyOnly); wizard.RenderTemplate(strTemplate, strFile, bCopyOnly);
if (strExt == ".h") { if (strExt == ".h") {
if (strName.indexOf("UnicodeScript") >= 0) { if (strName.indexOf("UnicodeScript.h") >= 0) {
unFile = proj.Object.AddFile(strFile); unFile = proj.Object.AddFile(strFile);
var strPrjTG3DirWin = '..\\..\\PRJ_TG3\\'; var strPrjTG3DirWin = '..\\..\\PRJ_TG3\\';
var unFileCfg = unFile.FileConfigurations('Debug'); var unFileCfg = unFile.FileConfigurations('Debug');

View File

@ -65,7 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() void AppDelegate::applicationDidEnterBackground()
{ {
CCDirector::sharedDirector()->stopAnimation(); CCDirector::sharedDirector()->pause();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
@ -75,7 +75,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again // this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() void AppDelegate::applicationWillEnterForeground()
{ {
CCDirector::sharedDirector()->startAnimation(); CCDirector::sharedDirector()->resume();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] [! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();

View File

@ -1,6 +1,9 @@
#include "AppDelegate.h" #include "AppDelegate.h"
#include "cocos2d.h" #include "cocos2d.h"
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
#include "SimpleAudioEngine.h"
[! endif]
#include "HelloWorldScene.h" #include "HelloWorldScene.h"
using namespace cocos2d; using namespace cocos2d;
@ -21,15 +24,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()
{ {
// init the window // init the window
#if defined(CCX_PLATFORM_UPHONE)
if (!(m_pMainWnd = new CCXEGLView(this)) ||
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
#elif defined(CCX_PLATFORM_WIN32)
if (!(m_pMainWnd = new CCXEGLView()) || if (!(m_pMainWnd = new CCXEGLView()) ||
! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) ) ! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) )
#else
#error
#endif
{ {
CCX_SAFE_DELETE(m_pMainWnd); CCX_SAFE_DELETE(m_pMainWnd);
return false; return false;
@ -42,11 +38,6 @@ bool AppDelegate::applicationDidFinishLaunching()
// pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait); // pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait);
pDirector->setDisplayFPS(true); pDirector->setDisplayFPS(true);
#if defined(CCX_PLATFORM_UPHONE)
// set the resource path
CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/cocos2d_tests/");
#endif
CCScene * pScene = HelloWorld::scene(); CCScene * pScene = HelloWorld::scene();
@ -57,10 +48,18 @@ bool AppDelegate::applicationDidFinishLaunching()
void AppDelegate::applicationDidEnterBackground() void AppDelegate::applicationDidEnterBackground()
{ {
CCDirector::sharedDirector()->stopAnimation(); CCDirector::sharedDirector()->pause();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
[! endif]
} }
void AppDelegate::applicationWillEnterForeground() void AppDelegate::applicationWillEnterForeground()
{ {
CCDirector::sharedDirector()->startAnimation(); CCDirector::sharedDirector()->resume();
[! if CCX_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE]
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
[! endif]
} }

View File

@ -14,5 +14,3 @@ Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
} }
return 1; return 1;
} }