mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1146 from walzer/gles20
change the param sequence of CCLabelTTF::create and initWithString, rding to JS APIs
This commit is contained in:
commit
2dc1f9ed7f
|
@ -79,28 +79,35 @@ CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontNam
|
||||||
|
|
||||||
CCLabelTTF * CCLabelTTF::create(const char *string, const char *fontName, float fontSize)
|
CCLabelTTF * CCLabelTTF::create(const char *string, const char *fontName, float fontSize)
|
||||||
{
|
{
|
||||||
return CCLabelTTF::create(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize);
|
return CCLabelTTF::create(string, fontName, fontSize,
|
||||||
|
CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize)
|
CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize)
|
||||||
{
|
{
|
||||||
return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize);
|
return CCLabelTTF::create(string, fontName, fontSize,
|
||||||
|
dimensions, hAlignment, kCCVerticalTextAlignmentTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLabelTTF * CCLabelTTF::create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize)
|
CCLabelTTF * CCLabelTTF::create(const char *string, const char *fontName, float fontSize,
|
||||||
|
const CCSize& dimensions, CCTextAlignment hAlignment)
|
||||||
{
|
{
|
||||||
return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize);
|
return CCLabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, kCCVerticalTextAlignmentTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
|
CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions,
|
||||||
|
CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment,
|
||||||
|
const char *fontName, float fontSize)
|
||||||
{
|
{
|
||||||
return CCLabelTTF::create(string, dimensions, hAlignment, vAlignment, fontName, fontSize);
|
return CCLabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, vAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLabelTTF* CCLabelTTF::create(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
|
CCLabelTTF* CCLabelTTF::create(const char *string, const char *fontName, float fontSize,
|
||||||
|
const CCSize &dimensions, CCTextAlignment hAlignment,
|
||||||
|
CCVerticalTextAlignment vAlignment)
|
||||||
{
|
{
|
||||||
CCLabelTTF *pRet = new CCLabelTTF();
|
CCLabelTTF *pRet = new CCLabelTTF();
|
||||||
if(pRet && pRet->initWithString(string, dimensions, hAlignment, vAlignment, fontName, fontSize))
|
if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment))
|
||||||
{
|
{
|
||||||
pRet->autorelease();
|
pRet->autorelease();
|
||||||
return pRet;
|
return pRet;
|
||||||
|
@ -114,17 +121,21 @@ bool CCLabelTTF::init()
|
||||||
return this->initWithString("", "Helvetica", 12);
|
return this->initWithString("", "Helvetica", 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
|
bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize,
|
||||||
|
const CCSize& dimensions, CCTextAlignment alignment)
|
||||||
{
|
{
|
||||||
return this->initWithString(label, dimensions, alignment, kCCVerticalTextAlignmentTop, fontName, fontSize);
|
return this->initWithString(label, fontName, fontSize, dimensions, alignment, kCCVerticalTextAlignmentTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
|
bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
|
||||||
{
|
{
|
||||||
return this->initWithString(label, CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop, fontName, fontSize);
|
return this->initWithString(label, fontName, fontSize,
|
||||||
|
CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCLabelTTF::initWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
|
bool CCLabelTTF::initWithString(const char *string, const char *fontName, float fontSize,
|
||||||
|
const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment,
|
||||||
|
CCVerticalTextAlignment vAlignment)
|
||||||
{
|
{
|
||||||
if (CCSprite::init())
|
if (CCSprite::init())
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,38 +59,43 @@ public:
|
||||||
@deprecated: This interface will be deprecated sooner or later.
|
@deprecated: This interface will be deprecated sooner or later.
|
||||||
@since v1.0
|
@since v1.0
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
|
CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize);
|
||||||
const char *fontName, float fontSize);
|
|
||||||
|
|
||||||
/** creates a CCLabel from a fontname, alignment, dimension in points and font size in points
|
/** creates a CCLabel from a fontname, alignment, dimension in points and font size in points
|
||||||
@deprecated: This interface will be deprecated sooner or later.
|
@deprecated: This interface will be deprecated sooner or later.
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
|
CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
|
||||||
CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
|
|
||||||
|
|
||||||
/** creates a CCLabelTTF with a font name and font size in points*/
|
/** creates a CCLabelTTF with a font name and font size in points
|
||||||
|
@since v2.0.1
|
||||||
|
*/
|
||||||
static CCLabelTTF * create(const char *string, const char *fontName, float fontSize);
|
static CCLabelTTF * create(const char *string, const char *fontName, float fontSize);
|
||||||
|
|
||||||
/** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points.
|
/** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points.
|
||||||
@since v1.0
|
@since v2.0.1
|
||||||
*/
|
*/
|
||||||
static CCLabelTTF * create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
|
static CCLabelTTF * create(const char *string, const char *fontName, float fontSize,
|
||||||
const char *fontName, float fontSize);
|
const CCSize& dimensions, CCTextAlignment hAlignment);
|
||||||
|
|
||||||
/** creates a CCLabel from a fontname, alignment, dimension in points and font size in points*/
|
/** creates a CCLabel from a fontname, alignment, dimension in points and font size in points
|
||||||
static CCLabelTTF * create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
|
@since v2.0.1
|
||||||
CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
|
*/
|
||||||
|
static CCLabelTTF * create(const char *string, const char *fontName, float fontSize,
|
||||||
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
const CCSize& dimensions, CCTextAlignment hAlignment,
|
||||||
bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize);
|
CCVerticalTextAlignment vAlignment);
|
||||||
|
|
||||||
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
|
||||||
bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
|
|
||||||
CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
|
|
||||||
|
|
||||||
/** initializes the CCLabelTTF with a font name and font size */
|
/** initializes the CCLabelTTF with a font name and font size */
|
||||||
bool initWithString(const char *string, const char *fontName, float fontSize);
|
bool initWithString(const char *string, const char *fontName, float fontSize);
|
||||||
|
|
||||||
|
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
||||||
|
bool initWithString(const char *string, const char *fontName, float fontSize,
|
||||||
|
const CCSize& dimensions, CCTextAlignment hAlignment);
|
||||||
|
|
||||||
|
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
||||||
|
bool initWithString(const char *string, const char *fontName, float fontSize,
|
||||||
|
const CCSize& dimensions, CCTextAlignment hAlignment,
|
||||||
|
CCVerticalTextAlignment vAlignment);
|
||||||
|
|
||||||
/** initializes the CCLabelTTF */
|
/** initializes the CCLabelTTF */
|
||||||
bool init();
|
bool init();
|
||||||
/** Creates an label.
|
/** Creates an label.
|
||||||
|
|
|
@ -194,12 +194,12 @@ public: virtual void set##funName(varType var) \
|
||||||
/*
|
/*
|
||||||
* only certain compilers support __attribute__((deprecated))
|
* only certain compilers support __attribute__((deprecated))
|
||||||
*/
|
*/
|
||||||
// #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||||
// #define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
|
#define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
|
||||||
// #elif _MSC_VER >= 1400 //vs 2005 or higher
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
||||||
// #define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated)
|
#define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated)
|
||||||
// #else
|
#else
|
||||||
#define CC_DEPRECATED_ATTRIBUTE
|
#define CC_DEPRECATED_ATTRIBUTE
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
#endif // __CC_PLATFORM_MACROS_H__
|
#endif // __CC_PLATFORM_MACROS_H__
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool CCTextFieldTTF::initWithPlaceHolder(const char *placeholder, const CCSize&
|
||||||
CC_SAFE_DELETE(m_pPlaceHolder);
|
CC_SAFE_DELETE(m_pPlaceHolder);
|
||||||
m_pPlaceHolder = new std::string(placeholder);
|
m_pPlaceHolder = new std::string(placeholder);
|
||||||
}
|
}
|
||||||
return CCLabelTTF::initWithString(m_pPlaceHolder->c_str(), dimensions, alignment, fontName, fontSize);
|
return CCLabelTTF::initWithString(m_pPlaceHolder->c_str(), fontName, fontSize, dimensions, alignment);
|
||||||
}
|
}
|
||||||
bool CCTextFieldTTF::initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize)
|
bool CCTextFieldTTF::initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,9 +94,12 @@ void FontTest::showFont(const char *pFont)
|
||||||
removeChildByTag(kTagLabel4, true);
|
removeChildByTag(kTagLabel4, true);
|
||||||
|
|
||||||
CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24);
|
CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24);
|
||||||
CCLabelTTF *left = CCLabelTTF::create("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize);
|
CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize,
|
||||||
CCLabelTTF *center = CCLabelTTF::create("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize);
|
blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]);
|
||||||
CCLabelTTF *right = CCLabelTTF::create("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize);
|
CCLabelTTF *center = CCLabelTTF::create("alignment center", pFont, fontSize,
|
||||||
|
blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx]);
|
||||||
|
CCLabelTTF *right = CCLabelTTF::create("alignment right", pFont, fontSize,
|
||||||
|
blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx]);
|
||||||
|
|
||||||
CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
|
CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
|
||||||
CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height);
|
CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height);
|
||||||
|
|
|
@ -371,17 +371,20 @@ LabelTTFAlignment::LabelTTFAlignment()
|
||||||
{
|
{
|
||||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
CCLabelTTF* ttf0 = CCLabelTTF::create("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12);
|
CCLabelTTF* ttf0 = CCLabelTTF::create("Alignment 0\nnew line", "Helvetica", 12,
|
||||||
|
CCSizeMake(256, 32), kCCTextAlignmentLeft);
|
||||||
ttf0->setPosition(ccp(s.width/2,(s.height/6)*2));
|
ttf0->setPosition(ccp(s.width/2,(s.height/6)*2));
|
||||||
ttf0->setAnchorPoint(ccp(0.5f,0.5f));
|
ttf0->setAnchorPoint(ccp(0.5f,0.5f));
|
||||||
this->addChild(ttf0);
|
this->addChild(ttf0);
|
||||||
|
|
||||||
CCLabelTTF* ttf1 = CCLabelTTF::create("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12);
|
CCLabelTTF* ttf1 = CCLabelTTF::create("Alignment 1\nnew line", "Helvetica", 12,
|
||||||
|
CCSizeMake(245, 32), kCCTextAlignmentCenter);
|
||||||
ttf1->setPosition(ccp(s.width/2,(s.height/6)*3));
|
ttf1->setPosition(ccp(s.width/2,(s.height/6)*3));
|
||||||
ttf1->setAnchorPoint(ccp(0.5f,0.5f));
|
ttf1->setAnchorPoint(ccp(0.5f,0.5f));
|
||||||
this->addChild(ttf1);
|
this->addChild(ttf1);
|
||||||
|
|
||||||
CCLabelTTF* ttf2 = CCLabelTTF::create("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12);
|
CCLabelTTF* ttf2 = CCLabelTTF::create("Alignment 2\nnew line", "Helvetica", 12,
|
||||||
|
CCSizeMake(245, 32), kCCTextAlignmentRight);
|
||||||
ttf2->setPosition(ccp(s.width/2,(s.height/6)*4));
|
ttf2->setPosition(ccp(s.width/2,(s.height/6)*4));
|
||||||
ttf2->setAnchorPoint(ccp(0.5f,0.5f));
|
ttf2->setAnchorPoint(ccp(0.5f,0.5f));
|
||||||
this->addChild(ttf2);
|
this->addChild(ttf2);
|
||||||
|
@ -997,7 +1000,8 @@ void LabelTTFTest::updateAlignment()
|
||||||
m_plabel->removeFromParentAndCleanup(true);
|
m_plabel->removeFromParentAndCleanup(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32);
|
m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), "Marker Felt", 32,
|
||||||
|
blockSize, m_eHorizAlign, m_eVertAlign);
|
||||||
m_plabel->retain();
|
m_plabel->retain();
|
||||||
|
|
||||||
m_plabel->setAnchorPoint(ccp(0,0));
|
m_plabel->setAnchorPoint(ccp(0,0));
|
||||||
|
@ -1087,11 +1091,11 @@ LabelTTFMultiline::LabelTTFMultiline()
|
||||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
CCLabelTTF *center = CCLabelTTF::create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"",
|
CCLabelTTF *center = CCLabelTTF::create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"",
|
||||||
CCSizeMake(s.width/2,200),
|
"Paint Boy",
|
||||||
kCCTextAlignmentCenter,
|
32,
|
||||||
kCCVerticalTextAlignmentTop,
|
CCSizeMake(s.width/2,200),
|
||||||
"Paint Boy",
|
kCCTextAlignmentCenter,
|
||||||
32);
|
kCCVerticalTextAlignmentTop);
|
||||||
|
|
||||||
center->setPosition(ccp(s.width / 2, 150));
|
center->setPosition(ccp(s.width / 2, 150));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue