Merge pull request #5806 from Dhilan007/develop_reImplementationWithLabel

issue #3821: Uses new label instead of LabelTTF in engine.
This commit is contained in:
James Chen 2014-03-25 13:46:17 +08:00
commit 8d28884c9f
20 changed files with 144 additions and 114 deletions

View File

@ -55,7 +55,7 @@ TextFieldTTF::TextFieldTTF()
: _delegate(0) : _delegate(0)
, _charCount(0) , _charCount(0)
, _inputText("") , _inputText("")
, _placeHolder("") // prevent LabelTTF initWithString assertion , _placeHolder("") // prevent Label initWithString assertion
, _secureTextEntry(false) , _secureTextEntry(false)
{ {
_colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127; _colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127;
@ -88,7 +88,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeho
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{ {
TextFieldTTF *ret = new TextFieldTTF(); TextFieldTTF *ret = new TextFieldTTF();
if(ret && ret->initWithString("", fontName, fontSize)) if(ret && ret->initWithPlaceHolder("", fontName, fontSize))
{ {
ret->autorelease(); ret->autorelease();
if (placeholder.size()>0) if (placeholder.size()>0)
@ -108,12 +108,22 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeho
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize) bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{ {
_placeHolder = placeholder; _placeHolder = placeholder;
return LabelTTF::initWithString(_placeHolder, fontName, fontSize, dimensions, alignment); setDimensions(dimensions.width,dimensions.height);
setFontName(fontName);
setFontSize(fontSize);
setAlignment(alignment,TextVAlignment::CENTER);
Label::setString(_placeHolder);
return true;
} }
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{ {
_placeHolder = std::string(placeholder); _placeHolder = std::string(placeholder);
return LabelTTF::initWithString(_placeHolder, fontName, fontSize); setFontName(fontName);
setFontSize(fontSize);
Label::setString(_placeHolder);
return true;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -228,7 +238,7 @@ void TextFieldTTF::deleteBackward()
{ {
_inputText = ""; _inputText = "";
_charCount = 0; _charCount = 0;
LabelTTF::setString(_placeHolder); Label::setString(_placeHolder);
return; return;
} }
@ -242,23 +252,19 @@ const std::string& TextFieldTTF::getContentText()
return _inputText; return _inputText;
} }
void TextFieldTTF::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) void TextFieldTTF::setColor(const Color3B& color)
{ {
if (_delegate && _delegate->onDraw(this)) _colorText = color;
{ Label::setColor(color);
return; }
}
if (_inputText.length())
{
LabelTTF::draw(renderer, transform, transformUpdated);
return;
}
// draw placeholder void TextFieldTTF::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
Color3B color = getColor(); {
setColor(_colorSpaceHolder); if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated))
LabelTTF::draw(renderer, transform, transformUpdated); {
setColor(color); return;
}
Label::visit(renderer,parentTransform,parentTransformUpdated);
} }
const Color3B& TextFieldTTF::getColorSpaceHolder() const Color3B& TextFieldTTF::getColorSpaceHolder()
@ -305,11 +311,13 @@ void TextFieldTTF::setString(const std::string &text)
// if there is no input text, display placeholder instead // if there is no input text, display placeholder instead
if (! _inputText.length()) if (! _inputText.length())
{ {
LabelTTF::setString(_placeHolder); Label::setColor(_colorSpaceHolder);
Label::setString(_placeHolder);
} }
else else
{ {
LabelTTF::setString(displayText); Label::setColor(_colorText);
Label::setString(displayText);
} }
_charCount = _calcCharCount(_inputText.c_str()); _charCount = _calcCharCount(_inputText.c_str());
} }
@ -325,7 +333,7 @@ void TextFieldTTF::setPlaceHolder(const std::string& text)
_placeHolder = text; _placeHolder = text;
if (! _inputText.length()) if (! _inputText.length())
{ {
LabelTTF::setString(_placeHolder); Label::setString(_placeHolder);
} }
} }

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#ifndef __CC_TEXT_FIELD_H__ #ifndef __CC_TEXT_FIELD_H__
#define __CC_TEXT_FIELD_H__ #define __CC_TEXT_FIELD_H__
#include "CCLabelTTF.h" #include "CCLabel.h"
#include "CCIMEDelegate.h" #include "CCIMEDelegate.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -86,7 +86,7 @@ public:
/** /**
@brief If the sender doesn't want to draw, return true. @brief If the sender doesn't want to draw, return true.
*/ */
virtual bool onDraw(TextFieldTTF * sender) virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{ {
CC_UNUSED_PARAM(sender); CC_UNUSED_PARAM(sender);
return false; return false;
@ -96,7 +96,7 @@ public:
/** /**
@brief A simple text input field with TTF font. @brief A simple text input field with TTF font.
*/ */
class CC_DLL TextFieldTTF : public LabelTTF, public IMEDelegate class CC_DLL TextFieldTTF : public Label, public IMEDelegate
{ {
public: public:
/** /**
@ -113,7 +113,7 @@ public:
/** creates a TextFieldTTF from a fontname, alignment, dimension and font size */ /** creates a TextFieldTTF from a fontname, alignment, dimension and font size */
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
/** creates a LabelTTF from a fontname and font size */ /** creates a TextFieldTTF from a fontname and font size */
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize);
/** initializes the TextFieldTTF with a font name, alignment, dimension and font size */ /** initializes the TextFieldTTF with a font name, alignment, dimension and font size */
bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
@ -148,33 +148,23 @@ public:
virtual const Color3B& getColorSpaceHolder(); virtual const Color3B& getColorSpaceHolder();
virtual void setColorSpaceHolder(const Color3B& color); virtual void setColorSpaceHolder(const Color3B& color);
virtual void setColor(const Color3B& color) override;
// input text property // input text property
public:
virtual void setString(const std::string& text) override; virtual void setString(const std::string& text) override;
virtual const std::string& getString() const override; virtual const std::string& getString() const override;
protected:
TextFieldDelegate * _delegate;
int _charCount;
std::string _inputText;
// place holder text property // place holder text property
// place holder text displayed when there is no text in the text field. // place holder text displayed when there is no text in the text field.
public:
virtual void setPlaceHolder(const std::string& text); virtual void setPlaceHolder(const std::string& text);
virtual const std::string& getPlaceHolder(void) const; virtual const std::string& getPlaceHolder(void) const;
protected:
std::string _placeHolder;
Color3B _colorSpaceHolder;
public:
virtual void setSecureTextEntry(bool value); virtual void setSecureTextEntry(bool value);
virtual bool isSecureTextEntry(); virtual bool isSecureTextEntry();
protected:
bool _secureTextEntry;
protected:
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override; virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
protected:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// IMEDelegate interface // IMEDelegate interface
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -184,6 +174,18 @@ protected:
virtual void insertText(const char * text, size_t len) override; virtual void insertText(const char * text, size_t len) override;
virtual void deleteBackward() override; virtual void deleteBackward() override;
virtual const std::string& getContentText() override; virtual const std::string& getContentText() override;
TextFieldDelegate * _delegate;
int _charCount;
std::string _inputText;
std::string _placeHolder;
Color3B _colorSpaceHolder;
Color3B _colorText;
bool _secureTextEntry;
private: private:
class LengthStack; class LengthStack;
LengthStack * _lens; LengthStack * _lens;

View File

@ -16,7 +16,7 @@ namespace cocosbuilder {
void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
((LabelTTF *)pNode)->setColor(pColor3B); ((Label *)pNode)->setColor(pColor3B);
} else { } else {
NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader);
} }
@ -24,7 +24,7 @@ void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const
void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
((LabelTTF *)pNode)->setOpacity(pByte); ((Label *)pNode)->setOpacity(pByte);
} else { } else {
NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader);
} }
@ -32,7 +32,7 @@ void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const ch
void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
((LabelTTF *)pNode)->setBlendFunc(pBlendFunc); ((Label *)pNode)->setBlendFunc(pBlendFunc);
} else { } else {
NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader);
} }
@ -40,7 +40,7 @@ void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, con
void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) { if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) {
((LabelTTF *)pNode)->setFontName(pFontTTF); ((Label *)pNode)->setFontName(pFontTTF);
} else { } else {
NodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader); NodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader);
} }
@ -48,7 +48,7 @@ void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const
void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { if(strcmp(pPropertyName, PROPERTY_STRING) == 0) {
((LabelTTF *)pNode)->setString(pText); ((Label *)pNode)->setString(pText);
} else { } else {
NodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, ccbReader); NodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, ccbReader);
} }
@ -56,7 +56,7 @@ void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const ch
void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) { if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) {
((LabelTTF *)pNode)->setFontSize(pFloatScale); ((Label *)pNode)->setFontSize(pFloatScale);
} else { } else {
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader); NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader);
} }
@ -64,19 +64,19 @@ void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, co
void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setHorizontalAlignment(TextHAlignment(pIntegerLabeled)); ((Label *)pNode)->setHorizontalAlignment(TextHAlignment(pIntegerLabeled));
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setVerticalAlignment(TextVAlignment(pIntegerLabeled)); ((Label *)pNode)->setVerticalAlignment(TextVAlignment(pIntegerLabeled));
} else { } else {
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader); NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader);
} }
} }
void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) { void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size size, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) { if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) {
((LabelTTF *)pNode)->setDimensions(pSize); ((Label *)pNode)->setDimensions(size.width,size.height);
} else { } else {
NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, size, ccbReader);
} }
} }

View File

@ -2,7 +2,7 @@
#define _CCB_CCLABELTTFLOADER_H_ #define _CCB_CCLABELTTFLOADER_H_
#include "CCRef.h" #include "CCRef.h"
#include "CCLabelTTF.h" #include "CCLabel.h"
#include "CCNodeLoader.h" #include "CCNodeLoader.h"
@ -21,7 +21,7 @@ public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTTFLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTTFLoader, loader);
protected: protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LabelTTF); CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Label);
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader);
virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader);

View File

@ -99,7 +99,8 @@ void Button::initRenderer()
_buttonNormalRenderer = Sprite::create(); _buttonNormalRenderer = Sprite::create();
_buttonClickedRenderer = Sprite::create(); _buttonClickedRenderer = Sprite::create();
_buttonDisableRenderer = Sprite::create(); _buttonDisableRenderer = Sprite::create();
_titleRenderer = LabelTTF::create(); _titleRenderer = Label::create();
_titleRenderer->setAnchorPoint(Point::ANCHOR_MIDDLE);
Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
@ -433,10 +434,10 @@ void Button::onPressStateChangedToDisabled()
void Button::updateFlippedX() void Button::updateFlippedX()
{ {
_titleRenderer->setFlippedX(_flippedX); float flip = _flippedX ? -1.0f : 1.0f;
_titleRenderer->setScaleX(flip);
if (_scale9Enabled) if (_scale9Enabled)
{ {
float flip = _flippedX ? -1.0f : 1.0f;
_buttonNormalRenderer->setScaleX(flip); _buttonNormalRenderer->setScaleX(flip);
_buttonClickedRenderer->setScaleX(flip); _buttonClickedRenderer->setScaleX(flip);
_buttonDisableRenderer->setScaleX(flip); _buttonDisableRenderer->setScaleX(flip);
@ -451,10 +452,10 @@ void Button::updateFlippedX()
void Button::updateFlippedY() void Button::updateFlippedY()
{ {
_titleRenderer->setFlippedY(_flippedY); float flip = _flippedY ? -1.0f : 1.0f;
_titleRenderer->setScaleY(flip);
if (_scale9Enabled) if (_scale9Enabled)
{ {
float flip = _flippedY ? -1.0f : 1.0f;
_buttonNormalRenderer->setScaleY(flip); _buttonNormalRenderer->setScaleY(flip);
_buttonClickedRenderer->setScaleY(flip); _buttonClickedRenderer->setScaleY(flip);
_buttonDisableRenderer->setScaleY(flip); _buttonDisableRenderer->setScaleY(flip);

View File

@ -195,7 +195,7 @@ protected:
Node* _buttonNormalRenderer; Node* _buttonNormalRenderer;
Node* _buttonClickedRenderer; Node* _buttonClickedRenderer;
Node* _buttonDisableRenderer; Node* _buttonDisableRenderer;
LabelTTF* _titleRenderer; Label* _titleRenderer;
std::string _normalFileName; std::string _normalFileName;
std::string _clickedFileName; std::string _clickedFileName;
std::string _disabledFileName; std::string _disabledFileName;

View File

@ -193,7 +193,7 @@ void RichText::formatText()
case RICH_TEXT: case RICH_TEXT:
{ {
RichElementText* elmtText = static_cast<RichElementText*>(element); RichElementText* elmtText = static_cast<RichElementText*>(element);
elementRenderer = LabelTTF::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize); elementRenderer = Label::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize);
break; break;
} }
case RICH_IMAGE: case RICH_IMAGE:
@ -255,7 +255,7 @@ void RichText::formatText()
void RichText::handleTextRenderer(const char *text, const char *fontName, float fontSize, const Color3B &color, GLubyte opacity) void RichText::handleTextRenderer(const char *text, const char *fontName, float fontSize, const Color3B &color, GLubyte opacity)
{ {
LabelTTF* textRenderer = LabelTTF::create(text, fontName, fontSize); Label* textRenderer = Label::create(text, fontName, fontSize);
float textRendererWidth = textRenderer->getContentSize().width; float textRendererWidth = textRenderer->getContentSize().width;
_leftSpaceWidth -= textRendererWidth; _leftSpaceWidth -= textRendererWidth;
if (_leftSpaceWidth < 0.0f) if (_leftSpaceWidth < 0.0f)
@ -268,7 +268,7 @@ void RichText::handleTextRenderer(const char *text, const char *fontName, float
std::string cutWords = curText.substr(leftLength, curText.length()-1); std::string cutWords = curText.substr(leftLength, curText.length()-1);
if (leftLength > 0) if (leftLength > 0)
{ {
LabelTTF* leftRenderer = LabelTTF::create(leftWords.substr(0, leftLength).c_str(), fontName, fontSize); Label* leftRenderer = Label::create(leftWords.substr(0, leftLength).c_str(), fontName, fontSize);
leftRenderer->setColor(color); leftRenderer->setColor(color);
leftRenderer->setOpacity(opacity); leftRenderer->setOpacity(opacity);
pushToContainer(leftRenderer); pushToContainer(leftRenderer);

View File

@ -71,7 +71,7 @@ bool Text::init()
void Text::initRenderer() void Text::initRenderer()
{ {
_labelRenderer = LabelTTF::create(); _labelRenderer = Label::create();
Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1); Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1);
} }
@ -117,7 +117,7 @@ const std::string& Text::getFontName()
void Text::setTextAreaSize(const Size &size) void Text::setTextAreaSize(const Size &size)
{ {
_labelRenderer->setDimensions(size); _labelRenderer->setDimensions(size.width,size.height);
labelScaleChangedWithSize(); labelScaleChangedWithSize();
} }
@ -164,7 +164,8 @@ void Text::onPressStateChangedToNormal()
{ {
return; return;
} }
_labelRenderer->setScale(_normalScaleValueX, _normalScaleValueY); _labelRenderer->setScaleX(_normalScaleValueX);
_labelRenderer->setScaleY(_normalScaleValueY);
} }
void Text::onPressStateChangedToPressed() void Text::onPressStateChangedToPressed()
@ -173,7 +174,8 @@ void Text::onPressStateChangedToPressed()
{ {
return; return;
} }
_labelRenderer->setScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset); _labelRenderer->setScaleX(_normalScaleValueX + _onSelectedScaleOffset);
_labelRenderer->setScaleY(_normalScaleValueY + _onSelectedScaleOffset);
} }
void Text::onPressStateChangedToDisabled() void Text::onPressStateChangedToDisabled()
@ -183,13 +185,26 @@ void Text::onPressStateChangedToDisabled()
void Text::updateFlippedX() void Text::updateFlippedX()
{ {
_labelRenderer->setFlippedX(_flippedX); if (_flippedX)
{
_labelRenderer->setScaleX(-1.0f);
}
else
{
_labelRenderer->setScaleX(1.0f);
}
} }
void Text::updateFlippedY() void Text::updateFlippedY()
{ {
_labelRenderer->setFlippedY(_flippedY); if (_flippedY)
{
_labelRenderer->setScaleY(-1.0f);
}
else
{
_labelRenderer->setScaleY(1.0f);
}
} }
void Text::setAnchorPoint(const Point &pt) void Text::setAnchorPoint(const Point &pt)
@ -218,14 +233,14 @@ void Text::labelScaleChangedWithSize()
{ {
if (_ignoreSize) if (_ignoreSize)
{ {
_labelRenderer->setDimensions(Size::ZERO); _labelRenderer->setDimensions(0,0);
_labelRenderer->setScale(1.0f); _labelRenderer->setScale(1.0f);
_size = _labelRenderer->getContentSize(); _size = _labelRenderer->getContentSize();
_normalScaleValueX = _normalScaleValueY = 1.0f; _normalScaleValueX = _normalScaleValueY = 1.0f;
} }
else else
{ {
_labelRenderer->setDimensions(_size); _labelRenderer->setDimensions(_size.width,_size.height);
Size textureSize = _labelRenderer->getContentSize(); Size textureSize = _labelRenderer->getContentSize();
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
{ {

View File

@ -159,7 +159,7 @@ protected:
std::string _fontName; std::string _fontName;
int _fontSize; int _fontSize;
float _onSelectedScaleOffset; float _onSelectedScaleOffset;
LabelTTF* _labelRenderer; Label* _labelRenderer;
}; };
} }

View File

@ -65,7 +65,7 @@ UICCTextField * UICCTextField::create(const char *placeholder, const char *fontN
{ {
UICCTextField *pRet = new UICCTextField(); UICCTextField *pRet = new UICCTextField();
if(pRet && pRet->initWithString("", fontName, fontSize)) if(pRet && pRet->initWithPlaceHolder("", fontName, fontSize))
{ {
pRet->autorelease(); pRet->autorelease();
if (placeholder) if (placeholder)
@ -296,7 +296,7 @@ void UICCTextField::setPasswordText(const char *text)
{ {
tempStr.append(_passwordStyleText); tempStr.append(_passwordStyleText);
} }
LabelTTF::setString(tempStr.c_str()); Label::setString(tempStr.c_str());
} }
void UICCTextField::setAttachWithIME(bool attach) void UICCTextField::setAttachWithIME(bool attach)
@ -672,13 +672,13 @@ void TextField::textfieldRendererScaleChangedWithSize()
{ {
if (_ignoreSize) if (_ignoreSize)
{ {
_textFieldRenderer->setDimensions(Size::ZERO); _textFieldRenderer->setDimensions(0,0);
_textFieldRenderer->setScale(1.0f); _textFieldRenderer->setScale(1.0f);
_size = getContentSize(); _size = getContentSize();
} }
else else
{ {
_textFieldRenderer->setDimensions(_size); _textFieldRenderer->setDimensions(_size.width,_size.height);
Size textureSize = getContentSize(); Size textureSize = getContentSize();
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
{ {
@ -754,7 +754,7 @@ void TextField::copySpecialProperties(Widget *widget)
void TextField::setTextAreaSize(const Size &size) void TextField::setTextAreaSize(const Size &size)
{ {
_textFieldRenderer->setDimensions(size); _textFieldRenderer->setDimensions(size.width,size.height);
} }
void TextField::setTextHorizontalAlignment(TextHAlignment alignment) void TextField::setTextHorizontalAlignment(TextHAlignment alignment)

View File

@ -27,7 +27,7 @@
#include "CCControlButton.h" #include "CCControlButton.h"
#include "CCScale9Sprite.h" #include "CCScale9Sprite.h"
#include "CCLabelTTF.h" #include "CCLabel.h"
#include "CCLabelBMFont.h" #include "CCLabelBMFont.h"
#include "CCAction.h" #include "CCAction.h"
#include "CCActionInterval.h" #include "CCActionInterval.h"
@ -65,7 +65,7 @@ ControlButton::~ControlButton()
bool ControlButton::init() bool ControlButton::init()
{ {
return this->initWithLabelAndBackgroundSprite(LabelTTF::create("", "Helvetica", 12), Scale9Sprite::create()); return this->initWithLabelAndBackgroundSprite(Label::create("", "Helvetica", 12), Scale9Sprite::create());
} }
bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* backgroundSprite) bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* backgroundSprite)
@ -132,7 +132,7 @@ ControlButton* ControlButton::create(Node* label, Scale9Sprite* backgroundSprite
bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize) bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize)
{ {
LabelTTF *label = LabelTTF::create(title, fontName, fontSize); Label *label = Label::create(title, fontName, fontSize);
return initWithLabelAndBackgroundSprite(label, Scale9Sprite::create()); return initWithLabelAndBackgroundSprite(label, Scale9Sprite::create());
} }
@ -146,7 +146,7 @@ ControlButton* ControlButton::create(const std::string& title, const std::string
bool ControlButton::initWithBackgroundSprite(Scale9Sprite* sprite) bool ControlButton::initWithBackgroundSprite(Scale9Sprite* sprite)
{ {
LabelTTF *label = LabelTTF::create("", "Arial", 30);// Label *label = Label::create("", "Arial", 30);//
return initWithLabelAndBackgroundSprite(label, sprite); return initWithLabelAndBackgroundSprite(label, sprite);
} }
@ -363,13 +363,13 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, State state)
void ControlButton::setTitleTTFForState(const std::string& fntFile, State state) void ControlButton::setTitleTTFForState(const std::string& fntFile, State state)
{ {
std::string title = this->getTitleForState(state); std::string title = this->getTitleForState(state);
this->setTitleLabelForState(LabelTTF::create(title, fntFile, 12), state); this->setTitleLabelForState(Label::create(title, fntFile, 12), state);
} }
const std::string& ControlButton::getTitleTTFForState(State state) const std::string& ControlButton::getTitleTTFForState(State state)
{ {
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state)); LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label); Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0) if(labelTTF != 0)
{ {
return labelTTF->getFontName(); return labelTTF->getFontName();
@ -384,7 +384,7 @@ void ControlButton::setTitleTTFSizeForState(float size, State state)
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state)); LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
if(label) if(label)
{ {
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label); Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0) if(labelTTF != 0)
{ {
return labelTTF->setFontSize(size); return labelTTF->setFontSize(size);
@ -395,7 +395,7 @@ void ControlButton::setTitleTTFSizeForState(float size, State state)
float ControlButton::getTitleTTFSizeForState(State state) float ControlButton::getTitleTTFSizeForState(State state)
{ {
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state)); LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label); Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0) if(labelTTF != 0)
{ {
return labelTTF->getFontSize(); return labelTTF->getFontSize();

View File

@ -89,8 +89,9 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
_minusSprite->setPosition( Point(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) ); _minusSprite->setPosition( Point(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) );
this->addChild(_minusSprite); this->addChild(_minusSprite);
this->setMinusLabel( LabelTTF::create("-", ControlStepperLabelFont, 40)); this->setMinusLabel( Label::create("-", ControlStepperLabelFont, 40));
_minusLabel->setColor(ControlStepperLabelColorDisabled); _minusLabel->setColor(ControlStepperLabelColorDisabled);
_minusLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
_minusLabel->setPosition(Point(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2) ); _minusLabel->setPosition(Point(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2) );
_minusSprite->addChild(_minusLabel); _minusSprite->addChild(_minusLabel);
@ -100,8 +101,9 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
minusSprite->getContentSize().height / 2) ); minusSprite->getContentSize().height / 2) );
this->addChild(_plusSprite); this->addChild(_plusSprite);
this->setPlusLabel( LabelTTF::create("+", ControlStepperLabelFont, 40 )); this->setPlusLabel( Label::create("+", ControlStepperLabelFont, 40 ));
_plusLabel->setColor( ControlStepperLabelColorEnabled ); _plusLabel->setColor( ControlStepperLabelColorEnabled );
_plusLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
_plusLabel->setPosition( Point(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2) ); _plusLabel->setPosition( Point(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2) );
_plusSprite->addChild(_plusLabel); _plusSprite->addChild(_plusLabel);

View File

@ -29,7 +29,7 @@
#define __CCCONTROLSTEPPER_H__ #define __CCCONTROLSTEPPER_H__
#include "CCControl.h" #include "CCControl.h"
#include "CCLabelTTF.h" #include "CCLabel.h"
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
@ -111,8 +111,8 @@ protected:
// Weak links to children // Weak links to children
CC_SYNTHESIZE_RETAIN(Sprite*, _minusSprite, MinusSprite) CC_SYNTHESIZE_RETAIN(Sprite*, _minusSprite, MinusSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _plusSprite, PlusSprite) CC_SYNTHESIZE_RETAIN(Sprite*, _plusSprite, PlusSprite)
CC_SYNTHESIZE_RETAIN(LabelTTF*, _minusLabel, MinusLabel) CC_SYNTHESIZE_RETAIN(Label*, _minusLabel, MinusLabel)
CC_SYNTHESIZE_RETAIN(LabelTTF*, _plusLabel, PlusLabel) CC_SYNTHESIZE_RETAIN(Label*, _plusLabel, PlusLabel)
}; };
// end of GUI group // end of GUI group

View File

@ -28,7 +28,7 @@
#include "CCControlSwitch.h" #include "CCControlSwitch.h"
#include "CCSprite.h" #include "CCSprite.h"
#include "CCActionTween.h" #include "CCActionTween.h"
#include "CCLabelTTF.h" #include "CCLabel.h"
#include "CCClippingNode.h" #include "CCClippingNode.h"
#include "ccShaders.h" #include "ccShaders.h"
#include "CCRenderTexture.h" #include "CCRenderTexture.h"
@ -45,8 +45,8 @@ public:
Sprite *onSprite, Sprite *onSprite,
Sprite *offSprite, Sprite *offSprite,
Sprite *thumbSprite, Sprite *thumbSprite,
LabelTTF* onLabel, Label* onLabel,
LabelTTF* offLabel); Label* offLabel);
/** /**
* @js NA * @js NA
@ -91,8 +91,8 @@ public:
CC_SYNTHESIZE_RETAIN(Sprite*, _onSprite, OnSprite) CC_SYNTHESIZE_RETAIN(Sprite*, _onSprite, OnSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _offSprite, OffSprite) CC_SYNTHESIZE_RETAIN(Sprite*, _offSprite, OffSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite) CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite)
CC_SYNTHESIZE_RETAIN(LabelTTF*, _onLabel, OnLabel) CC_SYNTHESIZE_RETAIN(Label*, _onLabel, OnLabel)
CC_SYNTHESIZE_RETAIN(LabelTTF*, _offLabel, OffLabel) CC_SYNTHESIZE_RETAIN(Label*, _offLabel, OffLabel)
Sprite* _clipperStencil; Sprite* _clipperStencil;
@ -116,8 +116,8 @@ protected:
Sprite *onSprite, Sprite *onSprite,
Sprite *offSprite, Sprite *offSprite,
Sprite *thumbSprite, Sprite *thumbSprite,
LabelTTF* onLabel, Label* onLabel,
LabelTTF* offLabel); Label* offLabel);
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(ControlSwitchSprite); CC_DISALLOW_COPY_AND_ASSIGN(ControlSwitchSprite);
}; };
@ -126,8 +126,8 @@ ControlSwitchSprite* ControlSwitchSprite::create(Sprite *maskSprite,
Sprite *onSprite, Sprite *onSprite,
Sprite *offSprite, Sprite *offSprite,
Sprite *thumbSprite, Sprite *thumbSprite,
LabelTTF* onLabel, Label* onLabel,
LabelTTF* offLabel) Label* offLabel)
{ {
auto ret = new ControlSwitchSprite(); auto ret = new ControlSwitchSprite();
ret->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); ret->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
@ -168,8 +168,8 @@ bool ControlSwitchSprite::initWithMaskSprite(
Sprite *onSprite, Sprite *onSprite,
Sprite *offSprite, Sprite *offSprite,
Sprite *thumbSprite, Sprite *thumbSprite,
LabelTTF* onLabel, Label* onLabel,
LabelTTF* offLabel) Label* offLabel)
{ {
if (Sprite::initWithTexture(maskSprite->getTexture())) if (Sprite::initWithTexture(maskSprite->getTexture()))
{ {
@ -254,11 +254,13 @@ void ControlSwitchSprite::needsLayout()
if (_onLabel) if (_onLabel)
{ {
_onLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
_onLabel->setPosition(Point(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6, _onLabel->setPosition(Point(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6,
_onSprite->getContentSize().height / 2)); _onSprite->getContentSize().height / 2));
} }
if (_offLabel) if (_offLabel)
{ {
_offLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
_offLabel->setPosition(Point(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6, _offLabel->setPosition(Point(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6,
_offSprite->getContentSize().height / 2)); _offSprite->getContentSize().height / 2));
} }
@ -330,7 +332,7 @@ ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Spri
return pRet; return pRet;
} }
bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel) bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
{ {
if (Control::init()) if (Control::init())
{ {
@ -359,7 +361,7 @@ bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sp
return false; return false;
} }
ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel) ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
{ {
ControlSwitch* pRet = new ControlSwitch(); ControlSwitch* pRet = new ControlSwitch();
if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel)) if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel))

View File

@ -32,7 +32,7 @@
namespace cocos2d { class Sprite; } namespace cocos2d { class Sprite; }
namespace cocos2d { class LabelTTF; } namespace cocos2d { class Label; }
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
@ -50,7 +50,7 @@ class ControlSwitch : public Control
{ {
public: public:
/** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel); static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite); static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
/** /**
@ -66,7 +66,7 @@ public:
/** Initializes a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ /** Initializes a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite); bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ /** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel); bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
/** /**
* Set the state of the switch to On or Off, optionally animating the transition. * Set the state of the switch to On or Off, optionally animating the transition.

View File

@ -87,7 +87,7 @@ Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Ref * pTa
bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) {
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", Sprite *, this->mBurstSprite); CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", Sprite *, this->mBurstSprite);
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", LabelTTF *, this->mTestTitleLabelTTF); CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", Label *, this->mTestTitleLabelTTF);
return false; return false;
} }

View File

@ -45,7 +45,7 @@ class HelloCocosBuilderLayer
private: private:
cocos2d::Sprite * mBurstSprite; cocos2d::Sprite * mBurstSprite;
cocos2d::LabelTTF * mTestTitleLabelTTF; cocos2d::Label * mTestTitleLabelTTF;
int mCustomPropertyInt; int mCustomPropertyInt;
float mCustomPropertyFloat; float mCustomPropertyFloat;

View File

@ -31,7 +31,7 @@ SEL_CallFuncN TimelineCallbackTestLayer::onResolveCCBCCCallFuncSelector(Ref * pT
} }
bool TimelineCallbackTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) { bool TimelineCallbackTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) {
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "helloLabel", LabelTTF *, this->_helloLabel); CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "helloLabel", Label *, this->_helloLabel);
return false; return false;
} }

View File

@ -24,7 +24,7 @@ class TimelineCallbackTestLayer
void onCallback1(Node* sender); void onCallback1(Node* sender);
void onCallback2(Node* sender); void onCallback2(Node* sender);
private: private:
cocos2d::LabelTTF* _helloLabel; cocos2d::Label* _helloLabel;
}; };
#endif /* _TIMELINE_TESTLAYER_H_ */ #endif /* _TIMELINE_TESTLAYER_H_ */

View File

@ -64,8 +64,8 @@ bool ControlSwitchTest::init()
Sprite::create("extensions/switch-on.png"), Sprite::create("extensions/switch-on.png"),
Sprite::create("extensions/switch-off.png"), Sprite::create("extensions/switch-off.png"),
Sprite::create("extensions/switch-thumb.png"), Sprite::create("extensions/switch-thumb.png"),
LabelTTF::create("On", "Arial-BoldMT", 16), Label::create("On", "Arial-BoldMT", 16),
LabelTTF::create("Off", "Arial-BoldMT", 16) Label::create("Off", "Arial-BoldMT", 16)
); );
switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0)); switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0));
layer->addChild(switchControl); layer->addChild(switchControl);