From 37bb33d9e501c23cadfe98cb4524157927cf2a03 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Apr 2011 15:10:09 +0800 Subject: [PATCH] fixed #452: refactor CCDirector CCNode CCGrid --- cocos2dx/Android.mk | 6 +- .../CCDirector_mobile.cpp => CCDirector.cpp} | 70 ------------------- .../CCNode.cpp} | 0 .../CCGrid_mobile.cpp => effects/CCGrid.cpp} | 0 cocos2dx/include/CCDirector.h | 53 ++------------ cocos2dx/proj.win32/cocos2d-win32.vcproj | 24 +++---- cocos2dx/proj.wophone/cocos2d-wophone.vcproj | 24 +++---- 7 files changed, 33 insertions(+), 144 deletions(-) rename cocos2dx/{platform/CCDirector_mobile.cpp => CCDirector.cpp} (90%) rename cocos2dx/{platform/CCNode_mobile.cpp => base_nodes/CCNode.cpp} (100%) rename cocos2dx/{platform/CCGrid_mobile.cpp => effects/CCGrid.cpp} (100%) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 7037db8e85..be2b839d77 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -21,6 +21,7 @@ actions/CCActionPageTurn3D.cpp \ actions/CCActionProgressTimer.cpp \ actions/CCActionTiledGrid.cpp \ base_nodes/CCAtlasNode.cpp \ +base_nodes/CCNode.cpp \ cocoa/CCAffineTransform.cpp \ cocoa/CCGeometry.cpp \ cocoa/CCAutoreleasePool.cpp \ @@ -30,7 +31,9 @@ cocoa/CCObject.cpp \ cocoa/CCSet.cpp \ cocoa/CCZone.cpp \ cocos2d.cpp \ +CCDirector.cpp \ effects/CCGrabber.cpp \ +effects/CCGrid.cpp \ keypad_dispatcher/CCKeypadDelegate.cpp \ keypad_dispatcher/CCKeypadDispatcher.cpp \ label_nodes/CCLabelAtlas.cpp \ @@ -50,10 +53,7 @@ particle_nodes/CCParticleExamples.cpp \ particle_nodes/CCParticleSystem.cpp \ particle_nodes/CCParticleSystemPoint.cpp \ particle_nodes/CCParticleSystemQuad.cpp \ -platform/CCDirector_mobile.cpp \ platform/CCFileUtils.cpp \ -platform/CCGrid_mobile.cpp \ -platform/CCNode_mobile.cpp \ platform/CCGL.cpp \ platform/CCImage.cpp \ platform/CCStdC.cpp \ diff --git a/cocos2dx/platform/CCDirector_mobile.cpp b/cocos2dx/CCDirector.cpp similarity index 90% rename from cocos2dx/platform/CCDirector_mobile.cpp rename to cocos2dx/CCDirector.cpp index 0a2ff0384a..fcf2c435b5 100644 --- a/cocos2dx/platform/CCDirector_mobile.cpp +++ b/cocos2dx/CCDirector.cpp @@ -262,14 +262,6 @@ void CCDirector::calculateDeltaTime(void) } -// m_dAnimationInterval -void CCDirector::setAnimationInterval(double dValue) -{ - CCLOG("cocos2d: Director#setAnimationInterval. Overrride me"); - // assert(0); -} - - // m_pobOpenGLView void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView) @@ -411,11 +403,6 @@ CCPoint CCDirector::convertToGL(CCPoint obPoint) ret.y = newX; break; } - -// if (m_fContentScaleFactor != 1 && m_bIsContentScaleSupported) -// { -// ret = ccpMult(ret, m_fContentScaleFactor); -// } return ret; } @@ -662,24 +649,6 @@ void CCDirector::resume(void) m_fDeltaTime = 0; } -void CCDirector::startAnimation(void) -{ - CCLOG("cocos2d: Director#startAnimation. Overrride me"); - assert(0); -} - -void CCDirector::stopAnimation(void) -{ - CCLOG("cocos2d: Director#stopAnimation. Overrride me"); - assert(0); -} - -void CCDirector::mainLoop(void) -{ - CCLOG("cocos2d: Director#preMainLoop. Overrride me"); - assert(0); -} - #if CC_DIRECTOR_FAST_FPS // display the FPS using a LabelAtlas // updates the FPS every frame @@ -900,45 +869,6 @@ void CCDirector::setDeviceOrientation(ccDeviceOrientation kDeviceOrientation) } } -/*************************************************** -* PC platforms specific functions, such as mac -**************************************************/ - -CCPoint CCDirector::convertEventToGL(CCEvent *event) -{ - assert(false); - return CCPointZero; -} - -bool CCDirector::isFullScreen(void) -{ - assert(false); - return false; -} - -void CCDirector::setResizeMode(int resizeMode) -{ - assert(false); -} - -int CCDirector::getResizeMode(void) -{ - assert(false); - return -1; -} - -void CCDirector::setFullScreen(bool fullscreen) -{ - assert(false); -} - -CCPoint CCDirector::convertToLogicalCoordinates(CCPoint coordinates) -{ - assert(false); - return CCPointZero; -} - - /*************************************************** * implementation of DisplayLinkDirector **************************************************/ diff --git a/cocos2dx/platform/CCNode_mobile.cpp b/cocos2dx/base_nodes/CCNode.cpp similarity index 100% rename from cocos2dx/platform/CCNode_mobile.cpp rename to cocos2dx/base_nodes/CCNode.cpp diff --git a/cocos2dx/platform/CCGrid_mobile.cpp b/cocos2dx/effects/CCGrid.cpp similarity index 100% rename from cocos2dx/platform/CCGrid_mobile.cpp rename to cocos2dx/effects/CCGrid.cpp diff --git a/cocos2dx/include/CCDirector.h b/cocos2dx/include/CCDirector.h index 50c349ffde..5208875abe 100644 --- a/cocos2dx/include/CCDirector.h +++ b/cocos2dx/include/CCDirector.h @@ -178,7 +178,6 @@ typedef enum { class CCLabelTTF; class CCScene; class CCEGLView; -class CCEvent; class CCNode; class CCProjectionProtocol; @@ -217,7 +216,7 @@ public: /** Get the FPS value */ inline double getAnimationInterval(void) { return m_dAnimationInterval; } /** Set the FPS value. */ - virtual void setAnimationInterval(double dValue); + virtual void setAnimationInterval(double dValue) = 0; /** Whether or not to display the FPS on the bottom-left corner */ inline bool isDisplayFPS(void) { return m_bDisplayFPS; } @@ -329,13 +328,13 @@ public: /** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead. */ - virtual void stopAnimation(void); + virtual void stopAnimation(void) = 0; /** The main loop is triggered again. Call this function only if [stopAnimation] was called earlier @warning Don't call this function to start the main loop. To run the main loop call runWithScene */ - virtual void startAnimation(void); + virtual void startAnimation(void) = 0; /** Draw the scene. This method is called every frame. Don't call it manually. @@ -361,16 +360,11 @@ public: /** enables/disables OpenGL depth test */ void setDepthTest(bool bOn); - virtual void mainLoop(void); + virtual void mainLoop(void) = 0; // Profiler void showProfilers(void); - - /*************************************************** - * mobile platforms specific functions - **************************************************/ - /** rotates the screen if an orientation different than Portrait is used */ void applyOrientation(void); @@ -431,31 +425,12 @@ public: /** detach the cocos2d view from the view/window */ bool detach(void); - /*************************************************** - * PC platforms specific functions, such as mac - **************************************************/ - CCPoint convertEventToGL(CCEvent *event); - // whether or not the view is in fullscreen mode - bool isFullScreen(void); - // resize mode: with or without scaling - void setResizeMode(int resizeMode); - int getResizeMode(void); - /** Sets the view in fullscreen or window mode */ - void setFullScreen(bool fullscreen); - /** Converts window size coordiantes to logical coordinates. - Useful only if resizeMode is kCCDirectorResize_Scale. - If resizeMode is kCCDirectorResize_NoScale, then no conversion will be done. - */ - CCPoint convertToLogicalCoordinates(CCPoint coordinates); - public: /** returns a shared instance of the director */ static CCDirector* sharedDirector(void); protected: - /*************************************************** - * mobile platforms specific functions - **************************************************/ + void purgeDirector(); bool m_bPurgeDirecotorInNextLoop; // this flag will be set to true in end() @@ -535,9 +510,6 @@ protected: /* Projection protocol delegate */ CCProjectionProtocol *m_pProjectionDelegate; - /*************************************************** - * mobile platforms specific members - **************************************************/ /* The device orientation */ ccDeviceOrientation m_eDeviceOrientation; /* contentScaleFactor could be simulated */ @@ -546,20 +518,7 @@ protected: tPixelFormat m_ePixelFormat; tDepthBufferFormat m_eDepthBufferFormat; - /*************************************************** - * mac platforms specific members - **************************************************/ - bool m_bIsFullScreen; - bool m_bRetinaDisplay; - int m_nResizeMode; - CCPoint m_winOffset; - CCSize m_originalWinSize; - - MacGLView *m_pFullScreenGLView; - NSWindow *m_pFullScreenWindow; - - // cache - MacGLView *m_pWindowGLView; + bool m_bRetinaDisplay; #if CC_ENABLE_PROFILERS ccTime m_fAccumDtForProfiler; diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 5726547c69..88e624021e 100644 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -191,6 +191,10 @@ RelativePath="..\base_nodes\CCAtlasNode.cpp" > + + + + @@ -727,10 +735,6 @@ RelativePath="..\platform\CCCommon.h" > - - @@ -751,10 +755,6 @@ RelativePath="..\platform\CCGL.h" > - - @@ -767,10 +767,6 @@ RelativePath="..\platform\CCLibxml2.h" > - - @@ -1056,6 +1052,10 @@ RelativePath="..\CCConfiguration.h" > + + diff --git a/cocos2dx/proj.wophone/cocos2d-wophone.vcproj b/cocos2dx/proj.wophone/cocos2d-wophone.vcproj index aec5e194c7..64a6cc79e6 100644 --- a/cocos2dx/proj.wophone/cocos2d-wophone.vcproj +++ b/cocos2dx/proj.wophone/cocos2d-wophone.vcproj @@ -240,6 +240,10 @@ RelativePath="..\base_nodes\CCAtlasNode.cpp" > + + + + @@ -916,10 +924,6 @@ RelativePath="..\platform\CCCommon.h" > - - @@ -940,10 +944,6 @@ RelativePath="..\platform\CCGL.h" > - - @@ -956,10 +956,6 @@ RelativePath="..\platform\CCLibxml2.h" > - - @@ -1077,6 +1073,10 @@ RelativePath="..\CCConfiguration.h" > + +