From 0298500abe631d95ce20a798bffe73385cedd925 Mon Sep 17 00:00:00 2001 From: Ming Date: Fri, 15 Oct 2010 07:47:48 +0000 Subject: [PATCH] add setContentScaleFactor() --- cocos2dx/CCDirector.cpp | 17 +++++++++++++++++ cocos2dx/include/CCDirector.h | 7 ++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 2dbfd2ab76..e737e56684 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -789,6 +789,23 @@ void CCDirector::showProfilers() } #endif +void CCDirector::setContentScaleFactor(CGFloat scaleFactor) +{ + if (scaleFactor != m_fContentScaleFactor) + { + m_fContentScaleFactor = scaleFactor; + m_obSurfaceSize = CGSizeMake(m_obScreenSize.width * scaleFactor, m_obScreenSize.height * scaleFactor); + + if (m_pobOpenGLView) + { + updateContentScaleFactor(); + } + + // update projection + setProjection(m_eProjection); + } +} + // should we afford 4 types of director ?? // I think DisplayLinkDirector is enough // so we now only support DisplayLinkDirector diff --git a/cocos2dx/include/CCDirector.h b/cocos2dx/include/CCDirector.h index 7ddc6c1e05..6eb542d0c1 100644 --- a/cocos2dx/include/CCDirector.h +++ b/cocos2dx/include/CCDirector.h @@ -246,11 +246,8 @@ public: Only available when compiled using SDK >= 4.0. @since v0.99.4 */ - inline void setContentScaleFactor(CGFloat obCGFloatValue) - { - assert(! isOpenGLAttached()); - m_fContentScaleFactor = obCGFloatValue; - } + void setContentScaleFactor(CGFloat scaleFactor); + inline CGFloat getContentScaleFactor(void) { return m_fContentScaleFactor; } // UI dependent