Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop_socket

This commit is contained in:
samuele3hu 2014-03-31 23:12:18 +08:00
commit 3ce597bc0e
6 changed files with 125 additions and 105 deletions

View File

@ -279,6 +279,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
, _currNumLines(-1) , _currNumLines(-1)
, _textSprite(nullptr) , _textSprite(nullptr)
, _contentDirty(false) , _contentDirty(false)
, _shadowDirty(false)
{ {
setAnchorPoint(Point::ANCHOR_MIDDLE); setAnchorPoint(Point::ANCHOR_MIDDLE);
reset(); reset();
@ -852,6 +853,7 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const
{ {
_shadowEnabled = true; _shadowEnabled = true;
_fontDefinition._shadow._shadowEnabled = false; _fontDefinition._shadow._shadowEnabled = false;
_shadowDirty = true;
_effectColor = shadowColor; _effectColor = shadowColor;
_effectColorF.r = _effectColor.r / 255.0f; _effectColorF.r = _effectColor.r / 255.0f;
@ -928,13 +930,11 @@ void Label::onDraw(const kmMat4& transform, bool transformUpdated)
} }
else if(_shadowEnabled && _shadowBlurRadius <= 0) else if(_shadowEnabled && _shadowBlurRadius <= 0)
{ {
trans = true;
kmGLPushMatrix();
drawShadowWithoutBlur(); drawShadowWithoutBlur();
} }
_shaderProgram->setUniformsForBuiltins(transform); _shaderProgram->setUniformsForBuiltins(transform);
for(const auto &child: _children) for(const auto &child: _children)
{ {
if(child->getTag() >= 0) if(child->getTag() >= 0)
@ -946,29 +946,17 @@ void Label::onDraw(const kmMat4& transform, bool transformUpdated)
batchNode->getTextureAtlas()->drawQuads(); batchNode->getTextureAtlas()->drawQuads();
} }
if (trans)
{
kmGLPopMatrix();
}
CC_PROFILER_STOP("Label - draw"); CC_PROFILER_STOP("Label - draw");
} }
void Label::drawShadowWithoutBlur() void Label::drawShadowWithoutBlur()
{ {
_position.x += _shadowOffset.width;
_position.y += _shadowOffset.height;
_transformDirty = _inverseDirty = true;
Color3B oldColor = _realColor; Color3B oldColor = _realColor;
GLubyte oldOPacity = _displayedOpacity; GLubyte oldOPacity = _displayedOpacity;
_displayedOpacity = _effectColorF.a * _displayedOpacity; _displayedOpacity = _effectColorF.a * _displayedOpacity;
setColor(_shadowColor); setColor(_shadowColor);
_modelViewTransform = transform(_parentTransform); _shaderProgram->setUniformsForBuiltins(_shadowTransform);
kmGLLoadMatrix(&_modelViewTransform);
_shaderProgram->setUniformsForBuiltins(_modelViewTransform);
for(const auto &child: _children) for(const auto &child: _children)
{ {
child->updateTransform(); child->updateTransform();
@ -978,15 +966,8 @@ void Label::drawShadowWithoutBlur()
batchNode->getTextureAtlas()->drawQuads(); batchNode->getTextureAtlas()->drawQuads();
} }
_position.x -= _shadowOffset.width;
_position.y -= _shadowOffset.height;
_transformDirty = _inverseDirty = true;
_displayedOpacity = oldOPacity; _displayedOpacity = oldOPacity;
setColor(oldColor); setColor(oldColor);
_modelViewTransform = transform(_parentTransform);
kmGLLoadMatrix(&_modelViewTransform);
} }
void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
@ -1121,36 +1102,45 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
updateContent(); updateContent();
} }
if (! _textSprite && _shadowEnabled && _shadowBlurRadius <= 0) bool dirty = parentTransformUpdated || _transformUpdated;
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty))
{ {
_parentTransform = parentTransform; _position.x += _shadowOffset.width;
draw(renderer, _modelViewTransform, true); _position.y += _shadowOffset.height;
_transformDirty = _inverseDirty = true;
_shadowTransform = transform(parentTransform);
_position.x -= _shadowOffset.width;
_position.y -= _shadowOffset.height;
_transformDirty = _inverseDirty = true;
_shadowDirty = false;
}
if(dirty)
{
_modelViewTransform = transform(parentTransform);
}
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
// but it is deprecated and your code should not rely on it
kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform);
if (_textSprite)
{
drawTextSprite(renderer,dirty);
} }
else else
{ {
bool dirty = parentTransformUpdated || _transformUpdated; draw(renderer, _modelViewTransform, dirty);
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
// but it is deprecated and your code should not rely on it
kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform);
if (_textSprite)
{
drawTextSprite(renderer,dirty);
}
else
{
draw(renderer, _modelViewTransform, dirty);
}
kmGLPopMatrix();
} }
kmGLPopMatrix();
setOrderOfArrival(0); setOrderOfArrival(0);
} }

View File

@ -368,10 +368,11 @@ protected:
GLuint _uniformTextColor; GLuint _uniformTextColor;
CustomCommand _customCommand; CustomCommand _customCommand;
bool _shadowDirty;
bool _shadowEnabled; bool _shadowEnabled;
Size _shadowOffset; Size _shadowOffset;
int _shadowBlurRadius; int _shadowBlurRadius;
kmMat4 _parentTransform; kmMat4 _shadowTransform;
Color3B _shadowColor; Color3B _shadowColor;
Sprite* _shadowNode; Sprite* _shadowNode;

View File

@ -306,6 +306,11 @@
-- @param self -- @param self
-- @return string#string ret (return value: string) -- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Label] setBlendFunc
-- @param self
-- @param #cc.BlendFunc blendfunc
-------------------------------- --------------------------------
-- @function [parent=#Label] visit -- @function [parent=#Label] visit
-- @param self -- @param self

View File

@ -1 +1 @@
cc2b5203a3684cb44db1ecc7b1e3423e070a993f 52a0d8b07b35e82b9c74faacb9c5437fe7396663

View File

@ -3,6 +3,13 @@
#include "renderer/CCRenderer.h" #include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h" #include "renderer/CCCustomCommand.h"
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
enum { enum {
kTagTileMap = 1, kTagTileMap = 1,
kTagSpriteManager = 1, kTagSpriteManager = 1,
@ -352,19 +359,19 @@ LabelTTFAlignment::LabelTTFAlignment()
Size(256, 32), TextHAlignment::LEFT); Size(256, 32), TextHAlignment::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::ANCHOR_MIDDLE);
this->addChild(ttf0); this->addChild(ttf0);
auto ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, auto ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12,
Size(245, 32), TextHAlignment::CENTER); Size(245, 32), TextHAlignment::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::ANCHOR_MIDDLE);
this->addChild(ttf1); this->addChild(ttf1);
auto ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, auto ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12,
Size(245, 32), TextHAlignment::RIGHT); Size(245, 32), TextHAlignment::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::ANCHOR_MIDDLE);
this->addChild(ttf2); this->addChild(ttf2);
} }
@ -398,11 +405,11 @@ Atlas3::Atlas3()
auto label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); auto label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt");
// testing anchors // testing anchors
label1->setAnchorPoint( Point(0,0) ); label1->setAnchorPoint( Point::ANCHOR_BOTTOM_LEFT );
addChild(label1, 0, kTagBitmapAtlas1); addChild(label1, 0, kTagBitmapAtlas1);
auto fade = FadeOut::create(1.0f); auto fade = FadeOut::create(1.0f);
auto fade_in = fade->reverse(); auto fade_in = fade->reverse();
auto seq = Sequence::create(fade, fade_in, NULL); auto seq = Sequence::create(fade, fade_in, nullptr);
auto repeat = RepeatForever::create(seq); auto repeat = RepeatForever::create(seq);
label1->runAction(repeat); label1->runAction(repeat);
@ -413,7 +420,7 @@ Atlas3::Atlas3()
// Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
auto label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); auto label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt");
// testing anchors // testing anchors
label2->setAnchorPoint( Point(0.5f, 0.5f) ); label2->setAnchorPoint( Point::ANCHOR_MIDDLE );
label2->setColor( Color3B::RED ); label2->setColor( Color3B::RED );
addChild(label2, 0, kTagBitmapAtlas2); addChild(label2, 0, kTagBitmapAtlas2);
auto tint = Sequence::create(TintTo::create(1, 255, 0, 0), auto tint = Sequence::create(TintTo::create(1, 255, 0, 0),
@ -424,7 +431,7 @@ Atlas3::Atlas3()
auto label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); auto label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt");
// testing anchors // testing anchors
label3->setAnchorPoint( Point(1,1) ); label3->setAnchorPoint( Point::ANCHOR_TOP_RIGHT );
addChild(label3, 0, kTagBitmapAtlas3); addChild(label3, 0, kTagBitmapAtlas3);
label1->setPosition( VisibleRect::leftBottom() ); label1->setPosition( VisibleRect::leftBottom() );
@ -484,7 +491,7 @@ Atlas4::Atlas4()
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
label->setPosition( Point(s.width/2, s.height/2) ); label->setPosition( Point(s.width/2, s.height/2) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
auto BChar = (Sprite*) label->getChildByTag(0); auto BChar = (Sprite*) label->getChildByTag(0);
@ -586,7 +593,7 @@ Atlas5::Atlas5()
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
label->setPosition( Point(s.width/2, s.height/2) ); label->setPosition( Point(s.width/2, s.height/2) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
} }
std::string Atlas5::title() const std::string Atlas5::title() const
@ -618,17 +625,17 @@ Atlas6::Atlas6()
label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, s.height/2+50) ); label->setPosition( Point(s.width/2, s.height/2+50) );
label->setAnchorPoint( Point(0.5f, 0.5f) ) ; label->setAnchorPoint( Point::ANCHOR_MIDDLE ) ;
label = LabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt");
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, s.height/2) ); label->setPosition( Point(s.width/2, s.height/2) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
label = LabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt");
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, s.height/2-50) ); label->setPosition( Point(s.width/2, s.height/2-50) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
} }
std::string Atlas6::title() const std::string Atlas6::title() const
@ -656,23 +663,23 @@ AtlasBitmapColor::AtlasBitmapColor()
{ {
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
LabelBMFont* label = NULL; LabelBMFont* label = nullptr;
label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt");
label->setColor( Color3B::BLUE ); label->setColor( Color3B::BLUE );
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, s.height/4) ); label->setPosition( Point(s.width/2, s.height/4) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
label = LabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt");
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, 2*s.height/4) ); label->setPosition( Point(s.width/2, 2*s.height/4) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
label->setColor( Color3B::RED ); label->setColor( Color3B::RED );
label = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt"); label = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt");
addChild(label); addChild(label);
label->setPosition( Point(s.width/2, 3*s.height/4) ); label->setPosition( Point(s.width/2, 3*s.height/4) );
label->setAnchorPoint( Point(0.5f, 0.5f) ); label->setAnchorPoint( Point::ANCHOR_MIDDLE );
label->setColor( Color3B::GREEN ); label->setColor( Color3B::GREEN );
label->setString("Green"); label->setString("Green");
} }
@ -713,7 +720,7 @@ AtlasFastBitmap::AtlasFastBitmap()
auto p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); auto p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height);
label->setPosition( p ); label->setPosition( p );
label->setAnchorPoint(Point(0.5f, 0.5f)); label->setAnchorPoint(Point::ANCHOR_MIDDLE);
} }
} }
@ -744,7 +751,7 @@ BitmapFontMultiLine::BitmapFontMultiLine()
// Left // Left
auto label1 = LabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); auto label1 = LabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt");
label1->setAnchorPoint(Point(0,0)); label1->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
addChild(label1, 0, kTagBitmapAtlas1); addChild(label1, 0, kTagBitmapAtlas1);
s = label1->getContentSize(); s = label1->getContentSize();
@ -753,7 +760,7 @@ BitmapFontMultiLine::BitmapFontMultiLine()
// Center // Center
auto label2 = LabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); auto label2 = LabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt");
label2->setAnchorPoint(Point(0.5f, 0.5f)); label2->setAnchorPoint(Point::ANCHOR_MIDDLE);
addChild(label2, 0, kTagBitmapAtlas2); addChild(label2, 0, kTagBitmapAtlas2);
s= label2->getContentSize(); s= label2->getContentSize();
@ -761,7 +768,7 @@ BitmapFontMultiLine::BitmapFontMultiLine()
// right // right
auto label3 = LabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); auto label3 = LabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt");
label3->setAnchorPoint(Point(1, 1)); label3->setAnchorPoint(Point::ANCHOR_TOP_RIGHT);
addChild(label3, 0, kTagBitmapAtlas3); addChild(label3, 0, kTagBitmapAtlas3);
s = label3->getContentSize(); s = label3->getContentSize();
@ -881,7 +888,7 @@ LabelAtlasHD::LabelAtlasHD()
// LabelBMFont // LabelBMFont
auto label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); auto label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist");
label1->setAnchorPoint(Point(0.5f, 0.5f)); label1->setAnchorPoint(Point::ANCHOR_MIDDLE);
addChild(label1); addChild(label1);
label1->setPosition(Point(s.width/2, s.height/2)); label1->setPosition(Point(s.width/2, s.height/2));
@ -945,7 +952,7 @@ LabelTTFTest::LabelTTFTest()
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
colorLayer->setAnchorPoint(Point(0,0)); colorLayer->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
colorLayer->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); colorLayer->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2));
this->addChild(colorLayer); this->addChild(colorLayer);
@ -969,7 +976,7 @@ LabelTTFTest::LabelTTFTest()
menu->setPosition(Point(s.width - 50, s.height / 2 - 20)); menu->setPosition(Point(s.width - 50, s.height / 2 - 20));
this->addChild(menu); this->addChild(menu);
_plabel = NULL; _label = nullptr;
_horizAlign = TextHAlignment::LEFT; _horizAlign = TextHAlignment::LEFT;
_vertAlign = TextVAlignment::TOP; _vertAlign = TextVAlignment::TOP;
@ -978,7 +985,7 @@ LabelTTFTest::LabelTTFTest()
LabelTTFTest::~LabelTTFTest() LabelTTFTest::~LabelTTFTest()
{ {
CC_SAFE_RELEASE(_plabel); CC_SAFE_RELEASE(_label);
} }
void LabelTTFTest::updateAlignment() void LabelTTFTest::updateAlignment()
@ -986,21 +993,21 @@ void LabelTTFTest::updateAlignment()
auto blockSize = Size(200, 160); auto blockSize = Size(200, 160);
auto s = Director::getInstance()->getWinSize(); auto s = Director::getInstance()->getWinSize();
if (_plabel) if (_label)
{ {
_plabel->removeFromParentAndCleanup(true); _label->removeFromParentAndCleanup(true);
} }
CC_SAFE_RELEASE(_plabel); CC_SAFE_RELEASE(_label);
_plabel = LabelTTF::create(this->getCurrentAlignment(), "fonts/Marker Felt.ttf", 32, _label = LabelTTF::create(this->getCurrentAlignment(), "fonts/Marker Felt.ttf", 32,
blockSize, _horizAlign, _vertAlign); blockSize, _horizAlign, _vertAlign);
_plabel->retain(); _label->retain();
_plabel->setAnchorPoint(Point(0,0)); _label->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_plabel->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); _label->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 ));
this->addChild(_plabel); this->addChild(_label);
} }
void LabelTTFTest::setAlignmentLeft(Ref* sender) void LabelTTFTest::setAlignmentLeft(Ref* sender)
@ -1163,13 +1170,13 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
auto size = Director::getInstance()->getWinSize(); auto 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, TextHAlignment::CENTER); _labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, TextHAlignment::CENTER);
this->_labelShouldRetain->retain(); _labelShouldRetain->retain();
this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); _arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png");
this->_arrowsBarShouldRetain->retain(); _arrowsBarShouldRetain->retain();
this->_arrowsShouldRetain = Sprite::create("Images/arrows.png"); _arrowsShouldRetain = Sprite::create("Images/arrows.png");
this->_arrowsShouldRetain->retain(); _arrowsShouldRetain->retain();
MenuItemFont::setFontSize(20); MenuItemFont::setFontSize(20);
auto longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); auto longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this));
@ -1199,24 +1206,24 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
right->setTag(RightAlign); right->setTag(RightAlign);
// position the label on the center of the screen // position the label on the center of the screen
this->_labelShouldRetain->setPosition(Point(size.width/2, size.height/2)); _labelShouldRetain->setPosition(Point(size.width/2, size.height/2));
this->_arrowsBarShouldRetain->setVisible(false); _arrowsBarShouldRetain->setVisible(false);
float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width; float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width;
this->_arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width); _arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width);
this->_arrowsBarShouldRetain->setPosition(Point(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); _arrowsBarShouldRetain->setPosition(Point(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y));
this->snapArrowsToEdge(); this->snapArrowsToEdge();
stringMenu->setPosition(Point(size.width/2, size.height - menuItemPaddingCenter)); stringMenu->setPosition(Point(size.width/2, size.height - menuItemPaddingCenter));
alignmentMenu->setPosition(Point(size.width/2, menuItemPaddingCenter+15)); alignmentMenu->setPosition(Point(size.width/2, menuItemPaddingCenter+15));
this->addChild(this->_labelShouldRetain); addChild(_labelShouldRetain);
this->addChild(this->_arrowsBarShouldRetain); addChild(_arrowsBarShouldRetain);
this->addChild(this->_arrowsShouldRetain); addChild(_arrowsShouldRetain);
this->addChild(stringMenu); addChild(stringMenu);
this->addChild(alignmentMenu); addChild(alignmentMenu);
} }
BitmapFontMultiLineAlignment::~BitmapFontMultiLineAlignment() BitmapFontMultiLineAlignment::~BitmapFontMultiLineAlignment()
@ -1246,13 +1253,13 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Ref *sender)
switch(item->getTag()) switch(item->getTag())
{ {
case LongSentences: case LongSentences:
this->_labelShouldRetain->setString(LongSentencesExample); _labelShouldRetain->setString(LongSentencesExample);
break; break;
case LineBreaks: case LineBreaks:
this->_labelShouldRetain->setString(LineBreaksExample); _labelShouldRetain->setString(LineBreaksExample);
break; break;
case Mixed: case Mixed:
this->_labelShouldRetain->setString(MixedExample); _labelShouldRetain->setString(MixedExample);
break; break;
default: default:
@ -1272,13 +1279,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Ref *sender)
switch(item->getTag()) switch(item->getTag())
{ {
case LeftAlign: case LeftAlign:
this->_labelShouldRetain->setAlignment(TextHAlignment::LEFT); _labelShouldRetain->setAlignment(TextHAlignment::LEFT);
break; break;
case CenterAlign: case CenterAlign:
this->_labelShouldRetain->setAlignment(TextHAlignment::CENTER); _labelShouldRetain->setAlignment(TextHAlignment::CENTER);
break; break;
case RightAlign: case RightAlign:
this->_labelShouldRetain->setAlignment(TextHAlignment::RIGHT); _labelShouldRetain->setAlignment(TextHAlignment::RIGHT);
break; break;
default: default:
@ -1325,7 +1332,7 @@ void BitmapFontMultiLineAlignment::onTouchesMoved(const std::vector<Touch*>& tou
float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2; float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2;
this->_labelShouldRetain->setWidth(labelWidth); _labelShouldRetain->setWidth(labelWidth);
} }
void BitmapFontMultiLineAlignment::snapArrowsToEdge() void BitmapFontMultiLineAlignment::snapArrowsToEdge()
@ -1736,3 +1743,9 @@ std::string LabelBMFontBinaryFormat::subtitle() const
{ {
return "This label uses font file in AngelCode binary format"; return "This label uses font file in AngelCode binary format";
} }
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif

View File

@ -4,6 +4,12 @@
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h" #include "../BaseTest.h"
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
class AtlasDemo : public BaseTest class AtlasDemo : public BaseTest
{ {
@ -235,8 +241,8 @@ private:
void updateAlignment(); void updateAlignment();
const char* getCurrentAlignment(); const char* getCurrentAlignment();
private: private:
LabelTTF* _plabel;
TextHAlignment _horizAlign; TextHAlignment _horizAlign;
LabelTTF* _label;
TextVAlignment _vertAlign; TextVAlignment _vertAlign;
}; };
@ -445,6 +451,11 @@ public:
virtual std::string subtitle() const override; virtual std::string subtitle() const override;
}; };
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif
// we don't support linebreak mode // we don't support linebreak mode