issue #2430:move enum in ccTypes.h class

This commit is contained in:
minggo 2013-07-25 18:46:43 +08:00
parent acdd1cfe9d
commit 2293630335
22 changed files with 172 additions and 163 deletions

View File

@ -114,8 +114,16 @@ const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_
const int kCCParticleModeGravity = ParticleSystem::MODE_GRAVITY; const int kCCParticleModeGravity = ParticleSystem::MODE_GRAVITY;
const int kCCParticleModeRadius = ParticleSystem::MODE_RADIUS; const int kCCParticleModeRadius = ParticleSystem::MODE_RADIUS;
const int kCCPositionTypeFree = ParticleSystem::FREE; const int kCCPositionTypeFree = ParticleSystem::POSITION_TYPE_FREE;
const int kCCPositionTypeRelative = ParticleSystem::RELATIVE; const int kCCPositionTypeRelative = ParticleSystem::POSITION_TYPE_RELATIVE;
const int kCCPositionTypeGrouped = ParticleSystem::GROUPED; const int kCCPositionTypeGrouped = ParticleSystem::POSITION_TYPE_GROUPED;
const int kCCVerticalTextAlignmentTop = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
const int kCCVerticalTextAlignmentCenter = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
const int kCCVerticalTextAlignmentBottom = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
const int kCCTextAlignmentLeft = Label::TEXT_ALIGNMENT_LEFT;
const int kCCTextAlignmentCenter = Label::TEXT_ALIGNMENT_CENTER;
const int kCCTextAlignmentRight = Label::TEXT_ALIGNMENT_RIGHT;
NS_CC_END NS_CC_END

View File

@ -789,8 +789,8 @@ CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow;
CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke; CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke;
CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition; CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition;
CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef Label::VerticalTextAlignment CCVerticalTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef Label::TextAlignment CCTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType; CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType;
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
@ -858,14 +858,13 @@ CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationDouble;
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationBoolean; CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationBoolean;
CC_DEPRECATED_ATTRIBUTE typedef enum Configuration::Type ccConfigurationType; CC_DEPRECATED_ATTRIBUTE typedef enum Configuration::Type ccConfigurationType;
#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentTop;
#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentCenter;
#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentBottom;
#define kCCTextAlignmentLeft kTextAlignmentLeft
#define kCCTextAlignmentCenter kTextAlignmentCenter
#define kCCTextAlignmentRight kTextAlignmentRight
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentLeft;
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentCenter;
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentRight;
#define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888 #define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888
#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888 #define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888

View File

@ -304,23 +304,27 @@ struct BlendFunc
const static BlendFunc BLEND_FUNC_DISABLE; const static BlendFunc BLEND_FUNC_DISABLE;
}; };
class Label
{
public:
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m // XXX: If any of these enums are edited and/or reordered, update Texture2D.m
//! Vertical text alignment type //! Vertical text alignment type
typedef enum enum VerticalTextAlignment
{ {
kVerticalTextAlignmentTop, VERTICAL_TEXT_ALIGNMENT_TOP,
kVerticalTextAlignmentCenter, VERTICAL_TEXT_ALIGNMENT_CENTER,
kVerticalTextAlignmentBottom, VERTICAL_TEXT_ALIGNMENT_BOTTOM,
} VerticalTextAlignment; };
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m // XXX: If any of these enums are edited and/or reordered, update Texture2D.m
//! Horizontal text alignment type //! Horizontal text alignment type
typedef enum enum TextAlignment
{ {
kTextAlignmentLeft, TEXT_ALIGNMENT_LEFT,
kTextAlignmentCenter, TEXT_ALIGNMENT_CENTER,
kTextAlignmentRight, TEXT_ALIGNMENT_RIGHT,
} TextAlignment; };
};
// types for animation in particle systems // types for animation in particle systems
@ -345,8 +349,6 @@ struct AnimationFrameData
Size size; Size size;
}; };
/** /**
types used for defining fonts properties (i.e. font name, size, stroke or shadow) types used for defining fonts properties (i.e. font name, size, stroke or shadow)
*/ */
@ -398,8 +400,8 @@ struct FontDefinition
public: public:
FontDefinition():_fontSize(0), FontDefinition():_fontSize(0),
_alignment(kTextAlignmentCenter), _alignment(Label::TEXT_ALIGNMENT_CENTER),
_vertAlignment(kVerticalTextAlignmentTop), _vertAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP),
_fontFillColor(Color3B::WHITE) _fontFillColor(Color3B::WHITE)
{ _dimensions = Size(0,0); } { _dimensions = Size(0,0); }
@ -408,9 +410,9 @@ public:
// font size // font size
int _fontSize; int _fontSize;
// horizontal alignment // horizontal alignment
TextAlignment _alignment; Label::Label::Label::TextAlignment _alignment;
// vertical alignment // vertical alignment
VerticalTextAlignment _vertAlignment; Label::Label::Label::VerticalTextAlignment _vertAlignment;
// renering box // renering box
Size _dimensions; Size _dimensions;
// font color // font color

View File

@ -430,23 +430,23 @@ LabelBMFont * LabelBMFont::create()
return NULL; return NULL;
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextAlignment alignment) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment)
{ {
return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO); return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO);
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width)
{ {
return LabelBMFont::create(str, fntFile, width, kTextAlignmentLeft, Point::ZERO); return LabelBMFont::create(str, fntFile, width, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
{ {
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
//LabelBMFont - Creation & Init //LabelBMFont - Creation & Init
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::TextAlignment alignment/* = Label::TEXT_ALIGNMENT_LEFT*/, Point imageOffset/* = Point::ZERO*/)
{ {
LabelBMFont *pRet = new LabelBMFont(); LabelBMFont *pRet = new LabelBMFont();
if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset)) if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset))
@ -460,10 +460,10 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid
bool LabelBMFont::init() bool LabelBMFont::init()
{ {
return initWithString(NULL, NULL, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); return initWithString(NULL, NULL, kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::TextAlignment alignment/* = Label::TEXT_ALIGNMENT_LEFT*/, Point imageOffset/* = Point::ZERO*/)
{ {
CCASSERT(!_configuration, "re-init is no longer supported"); CCASSERT(!_configuration, "re-init is no longer supported");
CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont"); CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
@ -530,7 +530,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
LabelBMFont::LabelBMFont() LabelBMFont::LabelBMFont()
: _string(NULL) : _string(NULL)
, _initialString(NULL) , _initialString(NULL)
, _alignment(kTextAlignmentCenter) , _alignment(Label::TEXT_ALIGNMENT_CENTER)
, _width(-1.0f) , _width(-1.0f)
, _configuration(NULL) , _configuration(NULL)
, _lineBreakWithoutSpaces(false) , _lineBreakWithoutSpaces(false)
@ -1094,7 +1094,7 @@ void LabelBMFont::updateLabel()
} }
// Step 2: Make alignment // Step 2: Make alignment
if (_alignment != kTextAlignmentLeft) if (_alignment != Label::TEXT_ALIGNMENT_LEFT)
{ {
int i = 0; int i = 0;
@ -1125,10 +1125,10 @@ void LabelBMFont::updateLabel()
float shift = 0; float shift = 0;
switch (_alignment) switch (_alignment)
{ {
case kTextAlignmentCenter: case Label::TEXT_ALIGNMENT_CENTER:
shift = getContentSize().width/2.0f - lineWidth/2.0f; shift = getContentSize().width/2.0f - lineWidth/2.0f;
break; break;
case kTextAlignmentRight: case Label::TEXT_ALIGNMENT_RIGHT:
shift = getContentSize().width - lineWidth; shift = getContentSize().width - lineWidth;
break; break;
default: default:
@ -1160,7 +1160,7 @@ void LabelBMFont::updateLabel()
} }
// LabelBMFont - Alignment // LabelBMFont - Alignment
void LabelBMFont::setAlignment(TextAlignment alignment) void LabelBMFont::setAlignment(Label::TextAlignment alignment)
{ {
this->_alignment = alignment; this->_alignment = alignment;
updateLabel(); updateLabel();

View File

@ -192,9 +192,9 @@ public:
static void purgeCachedData(); static void purgeCachedData();
/** creates a bitmap font atlas with an initial string and the FNT file */ /** creates a bitmap font atlas with an initial string and the FNT file */
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment, Point imageOffset); static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment, Point imageOffset);
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment); static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment);
static LabelBMFont * create(const char *str, const char *fntFile, float width); static LabelBMFont * create(const char *str, const char *fntFile, float width);
@ -206,7 +206,7 @@ public:
bool init(); bool init();
/** init a bitmap font atlas with an initial string and the FNT file */ /** init a bitmap font atlas with an initial string and the FNT file */
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextAlignment alignment = kTextAlignmentLeft, Point imageOffset = Point::ZERO); bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, Label::TextAlignment alignment = Label::TEXT_ALIGNMENT_LEFT, Point imageOffset = Point::ZERO);
/** updates the font chars based on the string to render */ /** updates the font chars based on the string to render */
void createFontChars(); void createFontChars();
@ -218,7 +218,7 @@ public:
virtual void setCString(const char *label); virtual void setCString(const char *label);
virtual void setAnchorPoint(const Point& var); virtual void setAnchorPoint(const Point& var);
virtual void updateLabel(); virtual void updateLabel();
virtual void setAlignment(TextAlignment alignment); virtual void setAlignment(Label::TextAlignment alignment);
virtual void setWidth(float width); virtual void setWidth(float width);
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
virtual void setScale(float scale); virtual void setScale(float scale);
@ -265,7 +265,7 @@ protected:
std::string _initialStringUTF8; std::string _initialStringUTF8;
// alignment of all lines // alignment of all lines
TextAlignment _alignment; Label::TextAlignment _alignment;
// max width until a line break is added // max width until a line break is added
float _width; float _width;

View File

@ -40,8 +40,8 @@ NS_CC_BEGIN
//CCLabelTTF //CCLabelTTF
// //
LabelTTF::LabelTTF() LabelTTF::LabelTTF()
: _alignment(kTextAlignmentCenter) : _alignment(Label::TEXT_ALIGNMENT_CENTER)
, _vAlignment(kVerticalTextAlignmentTop) , _vAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP)
, _fontName(NULL) , _fontName(NULL)
, _fontSize(0.0) , _fontSize(0.0)
, _string("") , _string("")
@ -73,18 +73,18 @@ LabelTTF * LabelTTF::create()
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize) LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize)
{ {
return LabelTTF::create(string, fontName, fontSize, return LabelTTF::create(string, fontName, fontSize,
Size::ZERO, kTextAlignmentCenter, kVerticalTextAlignmentTop); Size::ZERO, Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize, LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment) const Size& dimensions, Label::TextAlignment hAlignment)
{ {
return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, kVerticalTextAlignmentTop); return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize, LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize,
const Size &dimensions, TextAlignment hAlignment, const Size &dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment) Label::VerticalTextAlignment vAlignment)
{ {
LabelTTF *pRet = new LabelTTF(); LabelTTF *pRet = new LabelTTF();
if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment)) if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment))
@ -114,20 +114,20 @@ bool LabelTTF::init()
} }
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize, bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment alignment) const Size& dimensions, Label::TextAlignment alignment)
{ {
return this->initWithString(label, fontName, fontSize, dimensions, alignment, kVerticalTextAlignmentTop); return this->initWithString(label, fontName, fontSize, dimensions, alignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize) bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
{ {
return this->initWithString(label, fontName, fontSize, return this->initWithString(label, fontName, fontSize,
Size::ZERO, kTextAlignmentLeft, kVerticalTextAlignmentTop); Size::ZERO, Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize, bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize,
const cocos2d::Size &dimensions, TextAlignment hAlignment, const cocos2d::Size &dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment) Label::VerticalTextAlignment vAlignment)
{ {
if (Sprite::init()) if (Sprite::init())
{ {
@ -193,12 +193,12 @@ const char* LabelTTF::description() const
return String::createWithFormat("<LabelTTF | FontName = %s, FontSize = %.1f>", _fontName->c_str(), _fontSize)->getCString(); return String::createWithFormat("<LabelTTF | FontName = %s, FontSize = %.1f>", _fontName->c_str(), _fontSize)->getCString();
} }
TextAlignment LabelTTF::getHorizontalAlignment() const Label::TextAlignment LabelTTF::getHorizontalAlignment() const
{ {
return _alignment; return _alignment;
} }
void LabelTTF::setHorizontalAlignment(TextAlignment alignment) void LabelTTF::setHorizontalAlignment(Label::TextAlignment alignment)
{ {
if (alignment != _alignment) if (alignment != _alignment)
{ {
@ -212,12 +212,12 @@ void LabelTTF::setHorizontalAlignment(TextAlignment alignment)
} }
} }
VerticalTextAlignment LabelTTF::getVerticalAlignment() const Label::VerticalTextAlignment LabelTTF::getVerticalAlignment() const
{ {
return _vAlignment; return _vAlignment;
} }
void LabelTTF::setVerticalAlignment(VerticalTextAlignment verticalAlignment) void LabelTTF::setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment)
{ {
if (verticalAlignment != _vAlignment) if (verticalAlignment != _vAlignment)
{ {

View File

@ -48,9 +48,9 @@ NS_CC_BEGIN
* Custom ttf file can be put in assets/ or external storage that the Application can access. * Custom ttf file can be put in assets/ or external storage that the Application can access.
* @code * @code
* LabelTTF *label1 = LabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize, * LabelTTF *label1 = LabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize,
* kTextAlignmentLeft, kVerticalTextAlignmentCenter); * Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
* LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize, * LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize,
* kTextAlignmentLeft, kVerticalTextAlignmentCenter); * Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
* @endcode * @endcode
* *
*/ */
@ -70,14 +70,14 @@ public:
@since v2.0.1 @since v2.0.1
*/ */
static LabelTTF * create(const char *string, const char *fontName, float fontSize, static LabelTTF * create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment); const Size& dimensions, Label::TextAlignment hAlignment);
/** creates a Label from a fontname, alignment, dimension in points and font size in points /** creates a Label from a fontname, alignment, dimension in points and font size in points
@since v2.0.1 @since v2.0.1
*/ */
static LabelTTF * create(const char *string, const char *fontName, float fontSize, static LabelTTF * create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment, const Size& dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment); Label::VerticalTextAlignment vAlignment);
/** Create a lable with string and a font definition*/ /** Create a lable with string and a font definition*/
@ -88,12 +88,12 @@ public:
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *string, const char *fontName, float fontSize, bool initWithString(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment); const Size& dimensions, Label::TextAlignment hAlignment);
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *string, const char *fontName, float fontSize, bool initWithString(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment, const Size& dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment); Label::VerticalTextAlignment vAlignment);
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition); bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition);
@ -136,11 +136,11 @@ public:
virtual void setString(const char *label); virtual void setString(const char *label);
virtual const char* getString(void) const; virtual const char* getString(void) const;
TextAlignment getHorizontalAlignment() const; Label::TextAlignment getHorizontalAlignment() const;
void setHorizontalAlignment(TextAlignment alignment); void setHorizontalAlignment(Label::TextAlignment alignment);
VerticalTextAlignment getVerticalAlignment() const; Label::VerticalTextAlignment getVerticalAlignment() const;
void setVerticalAlignment(VerticalTextAlignment verticalAlignment); void setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment);
const Size& getDimensions() const; const Size& getDimensions() const;
void setDimensions(const Size &dim); void setDimensions(const Size &dim);
@ -162,9 +162,9 @@ protected:
/** Dimensions of the label in Points */ /** Dimensions of the label in Points */
Size _dimensions; Size _dimensions;
/** The alignment of the label */ /** The alignment of the label */
TextAlignment _alignment; Label::TextAlignment _alignment;
/** The vertical alignment of the label */ /** The vertical alignment of the label */
VerticalTextAlignment _vAlignment; Label::VerticalTextAlignment _vAlignment;
/** Font name used in the label */ /** Font name used in the label */
std::string * _fontName; std::string * _fontName;
/** Font size of the label */ /** Font size of the label */

View File

@ -112,7 +112,7 @@ ParticleSystem::ParticleSystem()
, _texture(NULL) , _texture(NULL)
, _opacityModifyRGB(false) , _opacityModifyRGB(false)
, _isBlendAdditive(false) , _isBlendAdditive(false)
, _positionType(PositionType::FREE) , _positionType(POSITION_TYPE_FREE)
, _isAutoRemoveOnFinish(false) , _isAutoRemoveOnFinish(false)
, _emitterMode(MODE_GRAVITY) , _emitterMode(MODE_GRAVITY)
{ {
@ -419,7 +419,7 @@ bool ParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
_blendFunc.dst = CC_BLEND_DST; _blendFunc.dst = CC_BLEND_DST;
// default movement type; // default movement type;
_positionType = PositionType::FREE; _positionType = POSITION_TYPE_FREE;
// by default be in mode A: // by default be in mode A:
_emitterMode = MODE_GRAVITY; _emitterMode = MODE_GRAVITY;
@ -520,11 +520,11 @@ void ParticleSystem::initParticle(tParticle* particle)
particle->deltaRotation = (endA - startA) / particle->timeToLive; particle->deltaRotation = (endA - startA) / particle->timeToLive;
// position // position
if (_positionType == PositionType::FREE) if (_positionType == POSITION_TYPE_FREE)
{ {
particle->startPos = this->convertToWorldSpace(Point::ZERO); particle->startPos = this->convertToWorldSpace(Point::ZERO);
} }
else if (_positionType == PositionType::RELATIVE) else if (_positionType == POSITION_TYPE_RELATIVE)
{ {
particle->startPos = _position; particle->startPos = _position;
} }
@ -628,11 +628,11 @@ void ParticleSystem::update(float dt)
_particleIdx = 0; _particleIdx = 0;
Point currentPosition = Point::ZERO; Point currentPosition = Point::ZERO;
if (_positionType == PositionType::FREE) if (_positionType == POSITION_TYPE_FREE)
{ {
currentPosition = this->convertToWorldSpace(Point::ZERO); currentPosition = this->convertToWorldSpace(Point::ZERO);
} }
else if (_positionType == PositionType::RELATIVE) else if (_positionType == POSITION_TYPE_RELATIVE)
{ {
currentPosition = _position; currentPosition = _position;
} }
@ -706,7 +706,7 @@ void ParticleSystem::update(float dt)
Point newPos; Point newPos;
if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE) if (_positionType == POSITION_TYPE_FREE || _positionType == POSITION_TYPE_RELATIVE)
{ {
Point diff = currentPosition - p->startPos; Point diff = currentPosition - p->startPos;
newPos = p->pos - diff; newPos = p->pos - diff;

View File

@ -139,15 +139,15 @@ public:
enum PositionType enum PositionType
{ {
/** Living particles are attached to the world and are unaffected by emitter repositioning. */ /** Living particles are attached to the world and are unaffected by emitter repositioning. */
FREE, POSITION_TYPE_FREE,
/** Living particles are attached to the world but will follow the emitter repositioning. /** Living particles are attached to the world but will follow the emitter repositioning.
Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite. Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
*/ */
RELATIVE, POSITION_TYPE_RELATIVE,
/** Living particles are attached to the emitter and are translated along with it. */ /** Living particles are attached to the emitter and are translated along with it. */
GROUPED, POSITION_TYPE_GROUPED,
}; };
//* @enum //* @enum

View File

@ -70,7 +70,7 @@ TextFieldTTF::~TextFieldTTF()
// static constructor // static constructor
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize)
{ {
TextFieldTTF *pRet = new TextFieldTTF(); TextFieldTTF *pRet = new TextFieldTTF();
if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
@ -106,7 +106,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, c
// initialize // initialize
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize)
{ {
if (placeholder) if (placeholder)
{ {

View File

@ -103,11 +103,11 @@ public:
//char * description(); //char * description();
/** 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 char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize);
/** creates a LabelTTF from a fontname and font size */ /** creates a LabelTTF from a fontname and font size */
static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *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 char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize);
/** initializes the TextFieldTTF with a font name and font size */ /** initializes the TextFieldTTF with a font name and font size */
bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize);

View File

@ -433,7 +433,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
} }
// implementation Texture2D (Text) // implementation Texture2D (Text)
bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, TextAlignment hAlignment/* = kTextAlignmentCenter */, VerticalTextAlignment vAlignment/* = kVerticalTextAlignmentTop */) bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, Label::TextAlignment hAlignment/* = Label::TEXT_ALIGNMENT_CENTER */, Label::VerticalTextAlignment vAlignment/* = Label::VERTICAL_TEXT_ALIGNMENT_TOP */)
{ {
FontDefinition tempDef; FontDefinition tempDef;
@ -461,20 +461,20 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
bool bRet = false; bool bRet = false;
Image::ETextAlign eAlign; Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment) if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
} }
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment) else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
} }
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment) else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
} }
else else
{ {

View File

@ -168,7 +168,7 @@ public:
bool initWithImage(Image * uiImage); bool initWithImage(Image * uiImage);
/** Initializes a texture from a string with dimensions, alignment, font name and font size */ /** Initializes a texture from a string with dimensions, alignment, font name and font size */
bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextAlignment hAlignment = kTextAlignmentCenter, VerticalTextAlignment vAlignment = kVerticalTextAlignmentTop); bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), Label::TextAlignment hAlignment = Label::TEXT_ALIGNMENT_CENTER, Label::VerticalTextAlignment vAlignment = Label::VERTICAL_TEXT_ALIGNMENT_TOP);
/** Initializes a texture from a string using a text definition*/ /** Initializes a texture from a string using a text definition*/
bool initWithString(const char *text, const FontDefinition& textDefinition); bool initWithString(const char *text, const FontDefinition& textDefinition);

View File

@ -64,9 +64,9 @@ void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, co
void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setHorizontalAlignment(TextAlignment(pIntegerLabeled)); ((LabelTTF *)pNode)->setHorizontalAlignment(Label::TextAlignment(pIntegerLabeled));
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setVerticalAlignment(VerticalTextAlignment(pIntegerLabeled)); ((LabelTTF *)pNode)->setVerticalAlignment(Label::VerticalTextAlignment(pIntegerLabeled));
} else { } else {
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
} }

View File

@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void)
menuRequest->addChild(itemTestEndpointDisconnect); menuRequest->addChild(itemTestEndpointDisconnect);
// Sahred Status Label // Sahred Status Label
_sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), kTextAlignmentLeft); _sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), Label::TEXT_ALIGNMENT_LEFT);
_sioClientStatus->setAnchorPoint(Point(0, 0)); _sioClientStatus->setAnchorPoint(Point(0, 0));
_sioClientStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y)); _sioClientStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y));
this->addChild(_sioClientStatus); this->addChild(_sioClientStatus);

View File

@ -49,19 +49,19 @@ WebSocketTestLayer::WebSocketTestLayer()
// Send Text Status Label // Send Text Status Label
_sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_sendTextStatus->setAnchorPoint(Point(0, 0)); _sendTextStatus->setAnchorPoint(Point(0, 0));
_sendTextStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25)); _sendTextStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25));
this->addChild(_sendTextStatus); this->addChild(_sendTextStatus);
// Send Binary Status Label // Send Binary Status Label
_sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_sendBinaryStatus->setAnchorPoint(Point(0, 0)); _sendBinaryStatus->setAnchorPoint(Point(0, 0));
_sendBinaryStatus->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25)); _sendBinaryStatus->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25));
this->addChild(_sendBinaryStatus); this->addChild(_sendBinaryStatus);
// Error Label // Error Label
_errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_errorStatus->setAnchorPoint(Point(0, 0)); _errorStatus->setAnchorPoint(Point(0, 0));
_errorStatus->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25)); _errorStatus->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25));
this->addChild(_errorStatus); this->addChild(_errorStatus);

View File

@ -39,11 +39,11 @@ static std::string fontList[] =
static int fontCount = sizeof(fontList) / sizeof(*fontList); static int fontCount = sizeof(fontList) / sizeof(*fontList);
static int vAlignIdx = 0; static int vAlignIdx = 0;
static VerticalTextAlignment verticalAlignment[] = static Label::VerticalTextAlignment verticalAlignment[] =
{ {
kVerticalTextAlignmentTop, Label::VERTICAL_TEXT_ALIGNMENT_TOP,
kVerticalTextAlignmentCenter, Label::VERTICAL_TEXT_ALIGNMENT_CENTER,
kVerticalTextAlignmentBottom, Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM,
}; };
static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment); static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment);
@ -99,11 +99,11 @@ void FontTest::showFont(const char *pFont)
LabelTTF *top = LabelTTF::create(pFont, pFont, 24); LabelTTF *top = LabelTTF::create(pFont, pFont, 24);
LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize, LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize,
blockSize, kTextAlignmentLeft, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_LEFT, verticalAlignment[vAlignIdx]);
LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize, LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize,
blockSize, kTextAlignmentCenter, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]);
LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize, LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize,
blockSize, kTextAlignmentRight, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_RIGHT, verticalAlignment[vAlignIdx]);
LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height); LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);

View File

@ -348,19 +348,19 @@ LabelTTFAlignment::LabelTTFAlignment()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12,
Size(256, 32), kTextAlignmentLeft); Size(256, 32), Label::TEXT_ALIGNMENT_LEFT);
ttf0->setPosition(Point(s.width/2,(s.height/6)*2)); ttf0->setPosition(Point(s.width/2,(s.height/6)*2));
ttf0->setAnchorPoint(Point(0.5f,0.5f)); ttf0->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf0); this->addChild(ttf0);
LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12,
Size(245, 32), kTextAlignmentCenter); Size(245, 32), Label::TEXT_ALIGNMENT_CENTER);
ttf1->setPosition(Point(s.width/2,(s.height/6)*3)); ttf1->setPosition(Point(s.width/2,(s.height/6)*3));
ttf1->setAnchorPoint(Point(0.5f,0.5f)); ttf1->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf1); this->addChild(ttf1);
LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12,
Size(245, 32), kTextAlignmentRight); Size(245, 32), Label::TEXT_ALIGNMENT_RIGHT);
ttf2->setPosition(Point(s.width/2,(s.height/6)*4)); ttf2->setPosition(Point(s.width/2,(s.height/6)*4));
ttf2->setAnchorPoint(Point(0.5f,0.5f)); ttf2->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf2); this->addChild(ttf2);
@ -953,8 +953,8 @@ LabelTTFTest::LabelTTFTest()
this->addChild(menu); this->addChild(menu);
_plabel = NULL; _plabel = NULL;
_horizAlign = kTextAlignmentLeft; _horizAlign = Label::TEXT_ALIGNMENT_LEFT;
_vertAlign = kVerticalTextAlignmentTop; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
this->updateAlignment(); this->updateAlignment();
} }
@ -988,37 +988,37 @@ void LabelTTFTest::updateAlignment()
void LabelTTFTest::setAlignmentLeft(Object* pSender) void LabelTTFTest::setAlignmentLeft(Object* pSender)
{ {
_horizAlign = kTextAlignmentLeft; _horizAlign = Label::TEXT_ALIGNMENT_LEFT;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentCenter(Object* pSender) void LabelTTFTest::setAlignmentCenter(Object* pSender)
{ {
_horizAlign = kTextAlignmentCenter; _horizAlign = Label::TEXT_ALIGNMENT_CENTER;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentRight(Object* pSender) void LabelTTFTest::setAlignmentRight(Object* pSender)
{ {
_horizAlign = kTextAlignmentRight; _horizAlign = Label::TEXT_ALIGNMENT_RIGHT;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentTop(Object* pSender) void LabelTTFTest::setAlignmentTop(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentTop; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentMiddle(Object* pSender) void LabelTTFTest::setAlignmentMiddle(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentCenter; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentBottom(Object* pSender) void LabelTTFTest::setAlignmentBottom(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentBottom; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
this->updateAlignment(); this->updateAlignment();
} }
@ -1027,24 +1027,24 @@ const char* LabelTTFTest::getCurrentAlignment()
const char* vertical = NULL; const char* vertical = NULL;
const char* horizontal = NULL; const char* horizontal = NULL;
switch (_vertAlign) { switch (_vertAlign) {
case kVerticalTextAlignmentTop: case Label::VERTICAL_TEXT_ALIGNMENT_TOP:
vertical = "Top"; vertical = "Top";
break; break;
case kVerticalTextAlignmentCenter: case Label::VERTICAL_TEXT_ALIGNMENT_CENTER:
vertical = "Middle"; vertical = "Middle";
break; break;
case kVerticalTextAlignmentBottom: case Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM:
vertical = "Bottom"; vertical = "Bottom";
break; break;
} }
switch (_horizAlign) { switch (_horizAlign) {
case kTextAlignmentLeft: case Label::TEXT_ALIGNMENT_LEFT:
horizontal = "Left"; horizontal = "Left";
break; break;
case kTextAlignmentCenter: case Label::TEXT_ALIGNMENT_CENTER:
horizontal = "Center"; horizontal = "Center";
break; break;
case kTextAlignmentRight: case Label::TEXT_ALIGNMENT_RIGHT:
horizontal = "Right"; horizontal = "Right";
break; break;
} }
@ -1070,8 +1070,8 @@ LabelTTFMultiline::LabelTTFMultiline()
"Paint Boy", "Paint Boy",
32, 32,
Size(s.width/2,200), Size(s.width/2,200),
kTextAlignmentCenter, Label::TEXT_ALIGNMENT_CENTER,
kVerticalTextAlignmentTop); Label::VERTICAL_TEXT_ALIGNMENT_TOP);
center->setPosition(Point(s.width / 2, 150)); center->setPosition(Point(s.width / 2, 150));
@ -1141,7 +1141,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
Size size = Director::getInstance()->getWinSize(); Size size = Director::getInstance()->getWinSize();
// create and initialize a Label // create and initialize a Label
this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kTextAlignmentCenter); this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, Label::TEXT_ALIGNMENT_CENTER);
this->_labelShouldRetain->retain(); this->_labelShouldRetain->retain();
this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png");
@ -1250,13 +1250,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender)
switch(item->getTag()) switch(item->getTag())
{ {
case LeftAlign: case LeftAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentLeft); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_LEFT);
break; break;
case CenterAlign: case CenterAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentCenter); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_CENTER);
break; break;
case RightAlign: case RightAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentRight); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_RIGHT);
break; break;
default: default:
@ -1348,11 +1348,11 @@ BMFontOneAtlas::BMFontOneAtlas()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
addChild(label1); addChild(label1);
label1->setPosition(Point(s.width/2, s.height/3*2)); label1->setPosition(Point(s.width/2, s.height/3*2));
auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point(0, 128)); auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point(0, 128));
addChild(label2); addChild(label2);
label2->setPosition(Point(s.width/2, s.height/3*1)); label2->setPosition(Point(s.width/2, s.height/3*1));
} }
@ -1379,7 +1379,7 @@ BMFontUnicode::BMFontUnicode()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kTextAlignmentLeft); auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, Label::TEXT_ALIGNMENT_LEFT);
addChild(label1); addChild(label1);
label1->setPosition(Point(s.width/2, s.height/5*4)); label1->setPosition(Point(s.width/2, s.height/5*4));

View File

@ -191,8 +191,8 @@ private:
const char* getCurrentAlignment(); const char* getCurrentAlignment();
private: private:
LabelTTF* _plabel; LabelTTF* _plabel;
TextAlignment _horizAlign; Label::TextAlignment _horizAlign;
VerticalTextAlignment _vertAlign; Label::VerticalTextAlignment _vertAlign;
}; };
class LabelTTFMultiline : public AtlasDemo class LabelTTFMultiline : public AtlasDemo

View File

@ -1157,12 +1157,12 @@ void ParticleDemo::toggleCallback(Object* pSender)
{ {
if (_emitter != NULL) if (_emitter != NULL)
{ {
if (_emitter->getPositionType() == ParticleSystem::GROUPED) if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_GROUPED)
_emitter->setPositionType(ParticleSystem::FREE); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
else if (_emitter->getPositionType() == ParticleSystem::FREE) else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_FREE)
_emitter->setPositionType(ParticleSystem::RELATIVE); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_RELATIVE);
else if (_emitter->getPositionType() == ParticleSystem::RELATIVE) else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_RELATIVE)
_emitter->setPositionType(ParticleSystem::GROUPED ); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED );
} }
} }
@ -1507,7 +1507,7 @@ void MultipleParticleSystems::onEnter()
particleSystem->setPosition(Point(i*50 ,i*50)); particleSystem->setPosition(Point(i*50 ,i*50));
particleSystem->setPositionType(ParticleSystem::GROUPED); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
addChild(particleSystem); addChild(particleSystem);
} }
@ -1564,7 +1564,7 @@ void MultipleParticleSystemsBatched::onEnter()
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist");
particleSystem->setPositionType(ParticleSystem::GROUPED); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setPosition(Point(i*50 ,i*50)); particleSystem->setPosition(Point(i*50 ,i*50));
batchNode->setTexture(particleSystem->getTexture()); batchNode->setTexture(particleSystem->getTexture());
@ -1627,7 +1627,7 @@ void AddAndDeleteParticleSystems::onEnter()
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
_batchNode->setTexture(particleSystem->getTexture()); _batchNode->setTexture(particleSystem->getTexture());
particleSystem->setPositionType(ParticleSystem::GROUPED); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setTotalParticles(200); particleSystem->setTotalParticles(200);
particleSystem->setPosition(Point(i*15 +100,i*15+100)); particleSystem->setPosition(Point(i*15 +100,i*15+100));
@ -1654,7 +1654,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt)
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
//add new //add new
particleSystem->setPositionType(ParticleSystem::GROUPED); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setTotalParticles(200); particleSystem->setTotalParticles(200);
particleSystem->setPosition(Point(rand() % 300 ,rand() % 400)); particleSystem->setPosition(Point(rand() % 300 ,rand() % 400));
@ -1781,7 +1781,7 @@ void ReorderParticleSystems::onEnter()
_batchNode->addChild(particleSystem); _batchNode->addChild(particleSystem);
particleSystem->setPositionType(ParticleSystem::FREE); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
particleSystem->release(); particleSystem->release();

View File

@ -2232,8 +2232,8 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
// defaul values // defaul values
const char * defautlFontName = "Arial"; const char * defautlFontName = "Arial";
const int defaultFontSize = 32; const int defaultFontSize = 32;
TextAlignment defaultTextAlignment = kTextAlignmentLeft; Label::TextAlignment defaultTextAlignment = Label::TEXT_ALIGNMENT_LEFT;
VerticalTextAlignment defaultTextVAlignment = kVerticalTextAlignmentTop; Label::VerticalTextAlignment defaultTextVAlignment = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
// by default shadow and stroke are off // by default shadow and stroke are off
out->_shadow._shadowEnabled = false; out->_shadow._shadowEnabled = false;
@ -2278,7 +2278,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr); JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr);
double fontAlign = 0.0; double fontAlign = 0.0;
JS_ValueToNumber(cx, jsr, &fontAlign); JS_ValueToNumber(cx, jsr, &fontAlign);
out->_alignment = (TextAlignment)(int)fontAlign; out->_alignment = (Label::TextAlignment)(int)fontAlign;
} }
else else
{ {
@ -2292,7 +2292,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr); JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr);
double fontAlign = 0.0; double fontAlign = 0.0;
JS_ValueToNumber(cx, jsr, &fontAlign); JS_ValueToNumber(cx, jsr, &fontAlign);
out->_vertAlignment = (VerticalTextAlignment)(int)fontAlign; out->_vertAlignment = (Label::VerticalTextAlignment)(int)fontAlign;
} }
else else
{ {

View File

@ -1 +1 @@
fe5cebe3d29124b8f96f14c8f048f35450a2b30e ff394f08219b7b2b4684dc07e14812540b28cd6e