From fe3aadf800b8f34c871cc2e7749a0d853ee4dd77 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Jul 2011 10:20:24 +0800 Subject: [PATCH] update to 1.0.0 07-12 --- cocos2dx/actions/CCAction.cpp | 6 ++---- cocos2dx/cocos2d.cpp | 2 +- cocos2dx/include/CCLabelAtlas.h | 8 ++++---- cocos2dx/include/CCMenuItem.h | 16 ++++++++-------- cocos2dx/include/CCTexture2D.h | 2 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 12 ++++++------ cocos2dx/menu_nodes/CCMenuItem.cpp | 24 ++++++++++++------------ cocos2dx/textures/CCTexture2D.cpp | 4 ++-- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 6249f58f1d..5e9bf298bf 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -305,7 +305,6 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone) void CCFollow::step(ccTime dt) { CC_UNUSED_PARAM(dt); -#define CLAMP(x,y,z) MIN(MAX(x,y),z) if(m_bBoundarySet) { @@ -315,14 +314,13 @@ void CCFollow::step(ccTime dt) CCPoint tempPos = ccpSub( m_obHalfScreenSize, m_pobFollowedNode->getPosition()); - m_pTarget->setPosition(ccp(CLAMP(tempPos.x, m_fLeftBoundary, m_fRightBoundary), - CLAMP(tempPos.y, m_fBottomBoundary, m_fTopBoundary))); + m_pTarget->setPosition(ccp(clampf(tempPos.x, m_fLeftBoundary, m_fRightBoundary), + clampf(tempPos.y, m_fBottomBoundary, m_fTopBoundary))); } else { m_pTarget->setPosition(ccpSub(m_obHalfScreenSize, m_pobFollowedNode->getPosition())); } -#undef CLAMP } bool CCFollow::isDone() diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 9288a409c3..311f1a8d56 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -29,7 +29,7 @@ namespace cocos2d { const char* cocos2dVersion() { - return "cocos2d v1.0.0-rc3"; + return "cocos2d v1.0.0"; } }//namespace cocos2d diff --git a/cocos2dx/include/CCLabelAtlas.h b/cocos2dx/include/CCLabelAtlas.h index 569e103012..95963d4dc9 100644 --- a/cocos2dx/include/CCLabelAtlas.h +++ b/cocos2dx/include/CCLabelAtlas.h @@ -50,16 +50,16 @@ namespace cocos2d{ m_sString.clear(); } /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element in points and the starting char of the atlas. @deprecated Will be removed in 1.0.1. Use "labelWithString:" instead */ - static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - bool initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); // super methods virtual void updateAtlasValues(); virtual void setString(const char *label); @@ -73,7 +73,7 @@ namespace cocos2d{ // string to render std::string m_sString; // the first char in the charmap - char m_cMapStartChar; + unsigned char m_cMapStartChar; }; }// namespace cocos2d diff --git a/cocos2dx/include/CCMenuItem.h b/cocos2dx/include/CCMenuItem.h index 5bd27c375e..9313536044 100644 --- a/cocos2dx/include/CCMenuItem.h +++ b/cocos2dx/include/CCMenuItem.h @@ -37,7 +37,7 @@ namespace cocos2d{ class CCLabelAtlas; class CCSprite; -#define kItemSize 32 +#define kCCItemSize 32 /** @brief CCMenuItem base class * @@ -148,12 +148,12 @@ namespace cocos2d{ class CC_DLL CCMenuItemFont : public CCMenuItemLabel { public: - CCMenuItemFont() : m_nFontSize(0), m_strFontName(""){} + CCMenuItemFont() : m_uFontSize(0), m_strFontName(""){} virtual ~CCMenuItemFont(){} /** set default font size */ - static void setFontSize(int s); + static void setFontSize(unsigned int s); /** get default font size */ - static int fontSize(); + static unsigned int fontSize(); /** set the default font name */ static void setFontName(const char *name); /** get the default font name */ @@ -169,10 +169,10 @@ namespace cocos2d{ * c++ can not overload static and non-static member functions with the same parameter types * so change the name to setFontSizeObj */ - void setFontSizeObj(int s); + void setFontSizeObj(unsigned int s); /** get font size */ - int getFontSize(); + unsigned int fontSizeObj(); /** set the font name * c++ can not overload static and non-static member functions with the same parameter types @@ -180,12 +180,12 @@ namespace cocos2d{ */ void setFontNameObj(const char* name); - const char* getFontName(); + const char* fontNameObj(); protected: void recreateLabel(); - int m_nFontSize; + unsigned int m_uFontSize; std::string m_strFontName; }; diff --git a/cocos2dx/include/CCTexture2D.h b/cocos2dx/include/CCTexture2D.h index 9c3be77873..0e6328424e 100644 --- a/cocos2dx/include/CCTexture2D.h +++ b/cocos2dx/include/CCTexture2D.h @@ -200,7 +200,7 @@ public: /** returns the bits-per-pixel of the in-memory OpenGL texture @since v1.0 */ - int bitsPerPixelForFormat(); + unsigned int bitsPerPixelForFormat(); /** sets the default pixel format for UIImages that contains alpha channel. diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index a4ba49722a..9edc543eff 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. namespace cocos2d{ //CCLabelAtlas - Creation & Init - CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) + CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned char startCharMap) { CCLabelAtlas *pRet = new CCLabelAtlas(); if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap)) @@ -44,12 +44,12 @@ namespace cocos2d{ return NULL; } - CCLabelAtlas * CCLabelAtlas::labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) + CCLabelAtlas * CCLabelAtlas::labelAtlasWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) { return labelWithString(label, charMapFile, itemWidth, itemHeight, startCharMap); } - bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) + bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) { assert(label != NULL); if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label))) @@ -64,17 +64,17 @@ namespace cocos2d{ //CCLabelAtlas - Atlas generation void CCLabelAtlas::updateAtlasValues() { - int n = m_sString.length(); + unsigned int n = m_sString.length(); ccV3F_C4B_T2F_Quad quad; - const char *s = m_sString.c_str(); + const unsigned char *s = (unsigned char*)m_sString.c_str(); CCTexture2D *texture = m_pTextureAtlas->getTexture(); float textureWide = (float) texture->getPixelsWide(); float textureHigh = (float) texture->getPixelsHigh(); - for( int i=0; isetFontName(_fontName.c_str()); - this->setFontSize(_fontSize); + m_strFontName = _fontName; + m_uFontSize = _fontSize; - CCLabelTTF *label = CCLabelTTF::labelWithString(value, _fontName.c_str(), (float)_fontSize); + CCLabelTTF *label = CCLabelTTF::labelWithString(value, m_strFontName.c_str(), (float)m_uFontSize); if (CCMenuItemLabel::initWithLabel(label, target, selector)) { // do something ? @@ -344,19 +344,19 @@ namespace cocos2d{ void CCMenuItemFont::recreateLabel() { CCLabelTTF *label = CCLabelTTF::labelWithString(m_pLabel->convertToLabelProtocol()->getString(), - m_strFontName.c_str(), (float)m_nFontSize); + m_strFontName.c_str(), (float)m_uFontSize); this->setLabel(label); } - void CCMenuItemFont::setFontSizeObj(int s) + void CCMenuItemFont::setFontSizeObj(unsigned int s) { - m_nFontSize = s; + m_uFontSize = s; recreateLabel(); } - int CCMenuItemFont::getFontSize() + unsigned int CCMenuItemFont::fontSizeObj() { - return m_nFontSize; + return m_uFontSize; } void CCMenuItemFont::setFontNameObj(const char* name) @@ -365,7 +365,7 @@ namespace cocos2d{ recreateLabel(); } - const char* CCMenuItemFont::getFontName() + const char* CCMenuItemFont::fontNameObj() { return m_strFontName.c_str(); } diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 80d46e5268..3eb9fa4891 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -633,9 +633,9 @@ CCTexture2DPixelFormat CCTexture2D::defaultAlphaPixelFormat() return g_defaultAlphaPixelFormat; } -int CCTexture2D::bitsPerPixelForFormat() +unsigned int CCTexture2D::bitsPerPixelForFormat() { - int ret= -1; + unsigned int ret = 0; switch (m_ePixelFormat) {