From d892872d2f3ae175588f92aff73474116504fc6d Mon Sep 17 00:00:00 2001 From: natural-law Date: Fri, 1 Jul 2011 09:32:15 +0800 Subject: [PATCH 1/2] fixed #552, Treat the parameter of method CCTextureCache::removeTextureForKey() as relative path. --- cocos2dx/textures/CCTextureCache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index a262fa8469..316405ed17 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -431,7 +431,8 @@ void CCTextureCache::removeTextureForKey(const char *textureKeyName) return; } - m_pTextures->removeObjectForKey(string(textureKeyName)); + string fullPath = CCFileUtils::fullPathFromRelativePath(textureKeyName); + m_pTextures->removeObjectForKey(fullPath); } CCTexture2D* CCTextureCache::textureForKey(const char* key) From 4d5dab4a40343b688413bbc41fcc2e4003347fbc Mon Sep 17 00:00:00 2001 From: natural-law Date: Fri, 1 Jul 2011 11:26:26 +0800 Subject: [PATCH 2/2] fixed #558, Upgrade folder layers_scenes_transitions_nodes to rc3. --- cocos2dx/include/CCLayer.h | 43 +++++--- cocos2dx/include/CCScene.h | 1 + cocos2dx/include/CCTransition.h | 1 + .../CCLayer.cpp | 98 ++++++++++++------- .../CCScene.cpp | 1 + .../CCTransition.cpp | 1 + .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tests/tests/MenuTest/MenuTest.cpp | 14 +-- 8 files changed, 102 insertions(+), 59 deletions(-) diff --git a/cocos2dx/include/CCLayer.h b/cocos2dx/include/CCLayer.h index f8e6d1210d..0314671ba3 100644 --- a/cocos2dx/include/CCLayer.h +++ b/cocos2dx/include/CCLayer.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -132,8 +133,8 @@ All features from CCLayer are valid, plus the following new features: class CC_DLL CCLayerColor : public CCLayer , public CCRGBAProtocol, public CCBlendProtocol { protected: - GLfloat m_pSquareVertices[4 * 2]; - GLubyte m_pSquareColors[4 * 4]; + ccVertex2F m_pSquareVertices[4]; + ccColor4B m_pSquareColors[4]; public: @@ -195,16 +196,18 @@ the background. All features from CCLayerColor are valid, plus the following new features: - direction - final color +- interpolation mode Color is interpolated between the startColor and endColor along the given vector (starting at the origin, ending at the terminus). If no vector is supplied, it defaults to (0, -1) -- a fade from top to bottom. -Given the nature of -the interpolation, you will not see either the start or end color for +If 'compressedInterpolation' is disabled, you will not see either the start or end color for non-cardinal vectors; a smooth gradient implying both end points will be still be drawn, however. +If ' compressedInterpolation' is enabled (default mode) you will see both the start and end colors of the gradient. + @since v0.99.5 */ class CC_DLL CCLayerGradient : public CCLayerColor @@ -222,14 +225,17 @@ public: /** Initializes the CCLayer with a gradient between start and end in the direction of v. */ virtual bool initWithColor(ccColor4B start, ccColor4B end, CCPoint v); - ccColor3B getStartColor(); - void setStartColor(ccColor3B colors); - + CC_PROPERTY(ccColor3B, m_startColor, StartColor) CC_PROPERTY(ccColor3B, m_endColor, EndColor) CC_PROPERTY(GLubyte, m_cStartOpacity, StartOpacity) CC_PROPERTY(GLubyte, m_cEndOpacity, EndOpacity) CC_PROPERTY(CCPoint, m_AlongVector, Vector) + /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors + Default: YES + */ + CC_PROPERTY(bool, m_bCompressedInterpolation, IsCompressedInterpolation) + LAYER_NODE_FUNC(CCLayerGradient); protected: virtual void updateColor(); @@ -240,24 +246,24 @@ Features: - It supports one or more children - Only one children will be active a time */ -class CC_DLL CCMultiplexLayer : public CCLayer +class CC_DLL CCLayerMultiplex : public CCLayer { protected: unsigned int m_nEnabledLayer; CCMutableArray * m_pLayers; public: - CCMultiplexLayer(); - virtual ~CCMultiplexLayer(); + CCLayerMultiplex(); + virtual ~CCLayerMultiplex(); - /** creates a CCMultiplexLayer with one or more layers using a variable argument list. */ - static CCMultiplexLayer * layerWithLayers(CCLayer* layer, ... ); + /** creates a CCLayerMultiplex with one or more layers using a variable argument list. */ + static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); /** * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. */ - static CCMultiplexLayer * layerWithLayer(CCLayer* layer); + static CCLayerMultiplex * layerWithLayer(CCLayer* layer); void addLayer(CCLayer* layer); bool initWithLayer(CCLayer* layer); @@ -272,7 +278,16 @@ public: */ void switchToAndReleaseMe(unsigned int n); - LAYER_NODE_FUNC(CCMultiplexLayer); + LAYER_NODE_FUNC(CCLayerMultiplex); +}; + +/** CCMultiplexLayer +It is the same as CCLayerMultiplex. + +@deprecated Use CCLayerMultiplex instead. This class will be removed in v1.0.1 +*/ +class CCMultiplexLayer : public CCLayerMultiplex +{ }; }//namespace cocos2d diff --git a/cocos2dx/include/CCScene.h b/cocos2dx/include/CCScene.h index 774d6862ed..79e41ee721 100644 --- a/cocos2dx/include/CCScene.h +++ b/cocos2dx/include/CCScene.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/include/CCTransition.h b/cocos2dx/include/CCTransition.h index 5918c9fb09..21edd67182 100644 --- a/cocos2dx/include/CCTransition.h +++ b/cocos2dx/include/CCTransition.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index ea6075fe78..5d6c704d27 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -55,6 +56,8 @@ bool CCLayer::init() CCDirector * pDirector; CC_BREAK_IF(!(pDirector = CCDirector::sharedDirector())); this->setContentSize(pDirector->getWinSize()); + m_bIsTouchEnabled = false; + m_bIsAccelerometerEnabled = false; // success bRet = true; } while(0); @@ -375,7 +378,8 @@ bool CCLayerColor::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfl for (unsigned int i=0; iupdateColor(); @@ -393,10 +397,10 @@ bool CCLayerColor::initWithColor(ccColor4B color) /// override contentSize void CCLayerColor::setContentSize(CCSize size) { - m_pSquareVertices[2] = size.width * CC_CONTENT_SCALE_FACTOR(); - m_pSquareVertices[5] = size.height * CC_CONTENT_SCALE_FACTOR(); - m_pSquareVertices[6] = size.width * CC_CONTENT_SCALE_FACTOR(); - m_pSquareVertices[7] = size.height * CC_CONTENT_SCALE_FACTOR(); + m_pSquareVertices[1].x = size.width * CC_CONTENT_SCALE_FACTOR(); + m_pSquareVertices[2].y = size.height * CC_CONTENT_SCALE_FACTOR(); + m_pSquareVertices[3].x = size.width * CC_CONTENT_SCALE_FACTOR(); + m_pSquareVertices[3].y = size.height * CC_CONTENT_SCALE_FACTOR(); CCLayer::setContentSize(size); } @@ -420,10 +424,10 @@ void CCLayerColor::updateColor() { for( unsigned int i=0; i < 4; i++ ) { - m_pSquareColors[i * 4] = m_tColor.r; - m_pSquareColors[i * 4 + 1] = m_tColor.g; - m_pSquareColors[i * 4 + 2] = m_tColor.b; - m_pSquareColors[i * 4 + 3] = m_cOpacity; + m_pSquareColors[i].r = m_tColor.r; + m_pSquareColors[i].g = m_tColor.g; + m_pSquareColors[i].b = m_tColor.b; + m_pSquareColors[i].a = m_cOpacity; } } @@ -501,6 +505,8 @@ bool CCLayerGradient::initWithColor(ccColor4B start, ccColor4B end, CCPoint v) m_AlongVector = v; start.a = 255; + m_bCompressedInterpolation = true; + return CCLayerColor::initWithColor(start); } @@ -508,13 +514,20 @@ void CCLayerGradient::updateColor() { CCLayerColor::updateColor(); - float h = sqrtf(m_AlongVector.x * m_AlongVector.x + m_AlongVector.y * m_AlongVector.y); + float h = ccpLength(m_AlongVector); if (h == 0) return; double c = sqrt(2.0); CCPoint u = ccp(m_AlongVector.x / h, m_AlongVector.y / h); + // Compressed Interpolation mode + if (m_bCompressedInterpolation) + { + float h2 = 1 / ( fabsf(u.x) + fabsf(u.y) ); + u = ccpMult(u, h2 * (float)c); + } + float opacityf = (float)m_cOpacity / 255.0f; ccColor4B S = { @@ -532,25 +545,25 @@ void CCLayerGradient::updateColor() }; // (-1, -1) - m_pSquareColors[0] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c))); - m_pSquareColors[1] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c))); - m_pSquareColors[2] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c))); - m_pSquareColors[3] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c))); + m_pSquareColors[0].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c))); + m_pSquareColors[0].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c))); + m_pSquareColors[0].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c))); + m_pSquareColors[0].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c))); // (1, -1) - m_pSquareColors[4] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c))); - m_pSquareColors[5] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c))); - m_pSquareColors[6] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c))); - m_pSquareColors[7] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c))); + m_pSquareColors[1].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c))); + m_pSquareColors[1].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c))); + m_pSquareColors[1].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c))); + m_pSquareColors[1].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c))); // (-1, 1) - m_pSquareColors[8] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c))); - m_pSquareColors[9] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c))); - m_pSquareColors[10] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c))); - m_pSquareColors[11] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c))); + m_pSquareColors[2].r = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c))); + m_pSquareColors[2].g = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c))); + m_pSquareColors[2].b = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c))); + m_pSquareColors[2].a = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c))); // (1, 1) - m_pSquareColors[12] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c))); - m_pSquareColors[13] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c))); - m_pSquareColors[14] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c))); - m_pSquareColors[15] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c))); + m_pSquareColors[3].r = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c))); + m_pSquareColors[3].g = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c))); + m_pSquareColors[3].b = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c))); + m_pSquareColors[3].a = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c))); } ccColor3B CCLayerGradient::getStartColor() @@ -607,24 +620,35 @@ CCPoint CCLayerGradient::getVector() return m_AlongVector; } +bool CCLayerGradient::getIsCompressedInterpolation() +{ + return m_bCompressedInterpolation; +} + +void CCLayerGradient::setIsCompressedInterpolation(bool compress) +{ + m_bCompressedInterpolation = compress; + updateColor(); +} + /// MultiplexLayer -CCMultiplexLayer::CCMultiplexLayer() +CCLayerMultiplex::CCLayerMultiplex() : m_nEnabledLayer(0) , m_pLayers(NULL) { } -CCMultiplexLayer::~CCMultiplexLayer() +CCLayerMultiplex::~CCLayerMultiplex() { CC_SAFE_RELEASE(m_pLayers); } -CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...) +CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) { va_list args; va_start(args,layer); - CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer(); + CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args)) { pMultiplexLayer->autorelease(); @@ -636,20 +660,20 @@ CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...) return NULL; } -CCMultiplexLayer * CCMultiplexLayer::layerWithLayer(CCLayer* layer) +CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) { - CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer(); + CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); pMultiplexLayer->initWithLayer(layer); pMultiplexLayer->autorelease(); return pMultiplexLayer; } -void CCMultiplexLayer::addLayer(CCLayer* layer) +void CCLayerMultiplex::addLayer(CCLayer* layer) { assert(m_pLayers); m_pLayers->addObject(layer); } -bool CCMultiplexLayer::initWithLayer(CCLayer* layer) +bool CCLayerMultiplex::initWithLayer(CCLayer* layer) { m_pLayers = new CCMutableArray(1); m_pLayers->addObject(layer); @@ -658,7 +682,7 @@ bool CCMultiplexLayer::initWithLayer(CCLayer* layer) return true; } -bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params) +bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params) { m_pLayers = new CCMutableArray(5); //m_pLayers->retain(); @@ -678,7 +702,7 @@ bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params) } -void CCMultiplexLayer::switchTo(unsigned int n) +void CCLayerMultiplex::switchTo(unsigned int n) { CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" ); @@ -689,7 +713,7 @@ void CCMultiplexLayer::switchTo(unsigned int n) this->addChild(m_pLayers->getObjectAtIndex(n)); } -void CCMultiplexLayer::switchToAndReleaseMe(unsigned int n) +void CCLayerMultiplex::switchToAndReleaseMe(unsigned int n) { CCAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" ); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index 6419440eee..36dbe9ea6d 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index e65fc6ba84..922f1edcad 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 1c8494ba0c..b892d69494 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -38bc28fc563959965a8c07d2e075ee119d679548 \ No newline at end of file +a82799555bac412b3b88dbdf222f8be8b39badb8 \ No newline at end of file diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index 615d1edca4..0ddd3e3470 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -112,12 +112,12 @@ MenuLayer1::~MenuLayer1() void MenuLayer1::menuCallback(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(1); + ((CCLayerMultiplex*)m_pParent)->switchTo(1); } void MenuLayer1::menuCallbackConfig(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(3); + ((CCLayerMultiplex*)m_pParent)->switchTo(3); } void MenuLayer1::menuCallbackDisabled(CCObject* sender) @@ -131,7 +131,7 @@ void MenuLayer1::menuCallbackEnable(CCObject* sender) void MenuLayer1::menuCallback2(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(2); + ((CCLayerMultiplex*)m_pParent)->switchTo(2); } void MenuLayer1::onQuit(CCObject* sender) @@ -223,7 +223,7 @@ void MenuLayer2::alignMenusV() void MenuLayer2::menuCallback(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(0); + ((CCLayerMultiplex*)m_pParent)->switchTo(0); } void MenuLayer2::menuCallbackOpacity(CCObject* sender) @@ -301,7 +301,7 @@ MenuLayer3::~MenuLayer3() void MenuLayer3::menuCallback(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(0); + ((CCLayerMultiplex*)m_pParent)->switchTo(0); } void MenuLayer3::menuCallback2(CCObject* sender) @@ -412,7 +412,7 @@ void MenuLayer4::menuCallback(CCObject* sender) void MenuLayer4::backCallback(CCObject* sender) { - ((CCMultiplexLayer*)m_pParent)->switchTo(0); + ((CCLayerMultiplex*)m_pParent)->switchTo(0); } void MenuTestScene::runThisTest() @@ -422,7 +422,7 @@ void MenuTestScene::runThisTest() CCLayer* pLayer3 = new MenuLayer3(); CCLayer* pLayer4 = new MenuLayer4(); - CCMultiplexLayer* layer = CCMultiplexLayer::layerWithLayers(pLayer1, pLayer2, pLayer3, pLayer4, NULL); + CCLayerMultiplex* layer = CCLayerMultiplex::layerWithLayers(pLayer1, pLayer2, pLayer3, pLayer4, NULL); addChild(layer, 0); pLayer1->release();