update to 1.0.0 07-12

This commit is contained in:
minggo 2011-07-13 10:20:24 +08:00
parent fcb2006fdc
commit fe3aadf800
8 changed files with 36 additions and 38 deletions

View File

@ -305,7 +305,6 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone)
void CCFollow::step(ccTime dt) void CCFollow::step(ccTime dt)
{ {
CC_UNUSED_PARAM(dt); CC_UNUSED_PARAM(dt);
#define CLAMP(x,y,z) MIN(MAX(x,y),z)
if(m_bBoundarySet) if(m_bBoundarySet)
{ {
@ -315,14 +314,13 @@ void CCFollow::step(ccTime dt)
CCPoint tempPos = ccpSub( m_obHalfScreenSize, m_pobFollowedNode->getPosition()); CCPoint tempPos = ccpSub( m_obHalfScreenSize, m_pobFollowedNode->getPosition());
m_pTarget->setPosition(ccp(CLAMP(tempPos.x, m_fLeftBoundary, m_fRightBoundary), m_pTarget->setPosition(ccp(clampf(tempPos.x, m_fLeftBoundary, m_fRightBoundary),
CLAMP(tempPos.y, m_fBottomBoundary, m_fTopBoundary))); clampf(tempPos.y, m_fBottomBoundary, m_fTopBoundary)));
} }
else else
{ {
m_pTarget->setPosition(ccpSub(m_obHalfScreenSize, m_pobFollowedNode->getPosition())); m_pTarget->setPosition(ccpSub(m_obHalfScreenSize, m_pobFollowedNode->getPosition()));
} }
#undef CLAMP
} }
bool CCFollow::isDone() bool CCFollow::isDone()

View File

@ -29,7 +29,7 @@ namespace cocos2d {
const char* cocos2dVersion() const char* cocos2dVersion()
{ {
return "cocos2d v1.0.0-rc3"; return "cocos2d v1.0.0";
} }
}//namespace cocos2d }//namespace cocos2d

View File

@ -50,16 +50,16 @@ namespace cocos2d{
m_sString.clear(); 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 */ /** 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. /** 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 @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 */ /** 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 // super methods
virtual void updateAtlasValues(); virtual void updateAtlasValues();
virtual void setString(const char *label); virtual void setString(const char *label);
@ -73,7 +73,7 @@ namespace cocos2d{
// string to render // string to render
std::string m_sString; std::string m_sString;
// the first char in the charmap // the first char in the charmap
char m_cMapStartChar; unsigned char m_cMapStartChar;
}; };
}// namespace cocos2d }// namespace cocos2d

View File

@ -37,7 +37,7 @@ namespace cocos2d{
class CCLabelAtlas; class CCLabelAtlas;
class CCSprite; class CCSprite;
#define kItemSize 32 #define kCCItemSize 32
/** @brief CCMenuItem base class /** @brief CCMenuItem base class
* *
@ -148,12 +148,12 @@ namespace cocos2d{
class CC_DLL CCMenuItemFont : public CCMenuItemLabel class CC_DLL CCMenuItemFont : public CCMenuItemLabel
{ {
public: public:
CCMenuItemFont() : m_nFontSize(0), m_strFontName(""){} CCMenuItemFont() : m_uFontSize(0), m_strFontName(""){}
virtual ~CCMenuItemFont(){} virtual ~CCMenuItemFont(){}
/** set default font size */ /** set default font size */
static void setFontSize(int s); static void setFontSize(unsigned int s);
/** get default font size */ /** get default font size */
static int fontSize(); static unsigned int fontSize();
/** set the default font name */ /** set the default font name */
static void setFontName(const char *name); static void setFontName(const char *name);
/** get the default font 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 * c++ can not overload static and non-static member functions with the same parameter types
* so change the name to setFontSizeObj * so change the name to setFontSizeObj
*/ */
void setFontSizeObj(int s); void setFontSizeObj(unsigned int s);
/** get font size */ /** get font size */
int getFontSize(); unsigned int fontSizeObj();
/** set the font name /** set the font name
* c++ can not overload static and non-static member functions with the same parameter types * 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); void setFontNameObj(const char* name);
const char* getFontName(); const char* fontNameObj();
protected: protected:
void recreateLabel(); void recreateLabel();
int m_nFontSize; unsigned int m_uFontSize;
std::string m_strFontName; std::string m_strFontName;
}; };

View File

@ -200,7 +200,7 @@ public:
/** returns the bits-per-pixel of the in-memory OpenGL texture /** returns the bits-per-pixel of the in-memory OpenGL texture
@since v1.0 @since v1.0
*/ */
int bitsPerPixelForFormat(); unsigned int bitsPerPixelForFormat();
/** sets the default pixel format for UIImages that contains alpha channel. /** sets the default pixel format for UIImages that contains alpha channel.

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
namespace cocos2d{ namespace cocos2d{
//CCLabelAtlas - Creation & Init //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(); CCLabelAtlas *pRet = new CCLabelAtlas();
if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap)) if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap))
@ -44,12 +44,12 @@ namespace cocos2d{
return NULL; 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); 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); assert(label != NULL);
if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label))) if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label)))
@ -64,17 +64,17 @@ namespace cocos2d{
//CCLabelAtlas - Atlas generation //CCLabelAtlas - Atlas generation
void CCLabelAtlas::updateAtlasValues() void CCLabelAtlas::updateAtlasValues()
{ {
int n = m_sString.length(); unsigned int n = m_sString.length();
ccV3F_C4B_T2F_Quad quad; 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(); CCTexture2D *texture = m_pTextureAtlas->getTexture();
float textureWide = (float) texture->getPixelsWide(); float textureWide = (float) texture->getPixelsWide();
float textureHigh = (float) texture->getPixelsHigh(); float textureHigh = (float) texture->getPixelsHigh();
for( int i=0; i<n; i++) { for(unsigned int i = 0; i < n; i++) {
unsigned char a = s[i] - m_cMapStartChar; unsigned char a = s[i] - m_cMapStartChar;
float row = (float) (a % m_uItemsPerRow); float row = (float) (a % m_uItemsPerRow);
float col = (float) (a / m_uItemsPerRow); float col = (float) (a / m_uItemsPerRow);

View File

@ -36,7 +36,7 @@ THE SOFTWARE.
namespace cocos2d{ namespace cocos2d{
static int _fontSize = kItemSize; static unsigned int _fontSize = kCCItemSize;
static std::string _fontName = "Marker Felt"; static std::string _fontName = "Marker Felt";
static bool _fontNameRelease = false; static bool _fontNameRelease = false;
@ -291,11 +291,11 @@ namespace cocos2d{
// //
//CCMenuItemFont //CCMenuItemFont
// //
void CCMenuItemFont::setFontSize(int s) void CCMenuItemFont::setFontSize(unsigned int s)
{ {
_fontSize = s; _fontSize = s;
} }
int CCMenuItemFont::fontSize() unsigned int CCMenuItemFont::fontSize()
{ {
return _fontSize; return _fontSize;
} }
@ -330,10 +330,10 @@ namespace cocos2d{
{ {
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
this->setFontName(_fontName.c_str()); m_strFontName = _fontName;
this->setFontSize(_fontSize); 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)) if (CCMenuItemLabel::initWithLabel(label, target, selector))
{ {
// do something ? // do something ?
@ -344,19 +344,19 @@ namespace cocos2d{
void CCMenuItemFont::recreateLabel() void CCMenuItemFont::recreateLabel()
{ {
CCLabelTTF *label = CCLabelTTF::labelWithString(m_pLabel->convertToLabelProtocol()->getString(), 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); this->setLabel(label);
} }
void CCMenuItemFont::setFontSizeObj(int s) void CCMenuItemFont::setFontSizeObj(unsigned int s)
{ {
m_nFontSize = s; m_uFontSize = s;
recreateLabel(); recreateLabel();
} }
int CCMenuItemFont::getFontSize() unsigned int CCMenuItemFont::fontSizeObj()
{ {
return m_nFontSize; return m_uFontSize;
} }
void CCMenuItemFont::setFontNameObj(const char* name) void CCMenuItemFont::setFontNameObj(const char* name)
@ -365,7 +365,7 @@ namespace cocos2d{
recreateLabel(); recreateLabel();
} }
const char* CCMenuItemFont::getFontName() const char* CCMenuItemFont::fontNameObj()
{ {
return m_strFontName.c_str(); return m_strFontName.c_str();
} }

View File

@ -633,9 +633,9 @@ CCTexture2DPixelFormat CCTexture2D::defaultAlphaPixelFormat()
return g_defaultAlphaPixelFormat; return g_defaultAlphaPixelFormat;
} }
int CCTexture2D::bitsPerPixelForFormat() unsigned int CCTexture2D::bitsPerPixelForFormat()
{ {
int ret= -1; unsigned int ret = 0;
switch (m_ePixelFormat) switch (m_ePixelFormat)
{ {