From a1753113b551137abf46abdddbeb6e92d36cc26e Mon Sep 17 00:00:00 2001 From: billy1380 Date: Sat, 16 Feb 2013 03:12:12 +0000 Subject: [PATCH] CCLens3d can be concave added boolean operator to enable the lens to be concave as well as convex --- cocos2dx/actions/CCActionGrid3D.cpp | 3 ++- cocos2dx/actions/CCActionGrid3D.h | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 1dd5f641f9..f24426c18d 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -367,6 +367,7 @@ bool CCLens3D::initWithDuration(float duration, const CCSize& gridSize, const CC setPosition(position); m_fRadius = radius; m_fLensEffect = 0.7f; + m_bConcave = false; m_bDirty = true; return true; @@ -438,7 +439,7 @@ void CCLens3D::update(float time) { vect = ccpNormalize(vect); CCPoint new_vect = ccpMult(vect, new_r); - v.z += ccpLength(new_vect) * m_fLensEffect; + v.z += (m_bConcave ? -1.0f : 1.0f) * ccpLength(new_vect) * m_fLensEffect; } } diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index f363005dd0..bf5cc40ab0 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -96,7 +96,9 @@ public: inline float getLensEffect(void) { return m_fLensEffect; } /** Set lens center position */ inline void setLensEffect(float fLensEffect) { m_fLensEffect = fLensEffect; } - + /** Set whether lens is concave */ + inline void setConcave(bool bConcave) { m_bConcave = bConcave; } + inline const CCPoint& getPosition(void) { return m_position; } void setPosition(const CCPoint& position); @@ -114,6 +116,8 @@ protected: float m_fRadius; /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ float m_fLensEffect; + /** lens is concave. (true = concave, false = convex) default is convex i.e. false */ + bool m_bConcave; bool m_bDirty; };