Merge pull request #394 from minggo/master

update to 1.0.0 07-12
This commit is contained in:
minggo 2011-07-12 19:24:08 -07:00
commit d0856f0e67
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)
{
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()

View File

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

View File

@ -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

View File

@ -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;
};

View File

@ -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.

View File

@ -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; i<n; i++) {
for(unsigned int i = 0; i < n; i++) {
unsigned char a = s[i] - m_cMapStartChar;
float row = (float) (a % m_uItemsPerRow);
float col = (float) (a / m_uItemsPerRow);

View File

@ -36,7 +36,7 @@ THE SOFTWARE.
namespace cocos2d{
static int _fontSize = kItemSize;
static unsigned int _fontSize = kCCItemSize;
static std::string _fontName = "Marker Felt";
static bool _fontNameRelease = false;
@ -291,11 +291,11 @@ namespace cocos2d{
//
//CCMenuItemFont
//
void CCMenuItemFont::setFontSize(int s)
void CCMenuItemFont::setFontSize(unsigned int s)
{
_fontSize = s;
}
int CCMenuItemFont::fontSize()
unsigned int CCMenuItemFont::fontSize()
{
return _fontSize;
}
@ -330,10 +330,10 @@ namespace cocos2d{
{
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
this->setFontName(_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();
}

View File

@ -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)
{