diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index b6802d3f0c..504d99bb71 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -357,7 +357,7 @@ void CCNode::setAnchorPoint(const CCPoint& point) } /// contentSize getter -CCSize CCNode::getContentSize() +const CCSize & CCNode::getContentSize() { return m_tContentSize; } diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp index e4d2170c45..e3b81118c3 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -449,12 +449,12 @@ void CCScrollView::performedAnimatedScroll(float dt) } -CCSize CCScrollView::getContentSize() +const CCSize & CCScrollView::getContentSize() { - return CCSizeMake(m_pContainer->getContentSize().width, m_pContainer->getContentSize().height); + return m_pContainer->getContentSize(); } -void CCScrollView::setContentSize(CCSize size) +void CCScrollView::setContentSize(const CCSize & size) { this->setViewSize(size); } diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index ad219c4643..72fc7a1f46 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -206,8 +206,8 @@ public: virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); - virtual void setContentSize(CCSize size); - virtual CCSize getContentSize(); + virtual void setContentSize(const CCSize & size); + virtual const CCSize & getContentSize(); /** * Determines whether it clips its children or not.