From cf59264dfeb43ab909a902a9e4e3db910fb1ce3a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 31 Mar 2014 08:52:27 +0000 Subject: [PATCH 1/6] [AUTO]: updating luabinding automatically --- cocos/scripting/lua-bindings/auto/api/Label.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 789d48198f..2ffec7b04e 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -306,6 +306,11 @@ -- @param self -- @return string#string ret (return value: string) +-------------------------------- +-- @function [parent=#Label] setBlendFunc +-- @param self +-- @param #cc.BlendFunc blendfunc + -------------------------------- -- @function [parent=#Label] visit -- @param self From 72811d88691a014f6e39675a246ccac25ec41fe4 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 31 Mar 2014 17:21:56 +0800 Subject: [PATCH 2/6] fixed warn in test case. --- .../cpp-tests/Classes/LabelTest/LabelTest.cpp | 77 +++++++++++-------- tests/cpp-tests/Classes/LabelTest/LabelTest.h | 6 +- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 1fb64b40ad..0c637c275f 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -3,6 +3,13 @@ #include "renderer/CCRenderer.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 { kTagTileMap = 1, kTagSpriteManager = 1, @@ -969,7 +976,7 @@ LabelTTFTest::LabelTTFTest() menu->setPosition(Point(s.width - 50, s.height / 2 - 20)); this->addChild(menu); - _plabel = NULL; + _label = nullptr; _horizAlign = TextHAlignment::LEFT; _vertAlign = TextVAlignment::TOP; @@ -978,7 +985,7 @@ LabelTTFTest::LabelTTFTest() LabelTTFTest::~LabelTTFTest() { - CC_SAFE_RELEASE(_plabel); + CC_SAFE_RELEASE(_label); } void LabelTTFTest::updateAlignment() @@ -986,21 +993,21 @@ void LabelTTFTest::updateAlignment() auto blockSize = Size(200, 160); 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); - _plabel->retain(); + _label->retain(); - _plabel->setAnchorPoint(Point(0,0)); - _plabel->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); + _label->setAnchorPoint(Point(0,0)); + _label->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); - this->addChild(_plabel); + this->addChild(_label); } void LabelTTFTest::setAlignmentLeft(Ref* sender) @@ -1163,13 +1170,13 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() auto size = Director::getInstance()->getWinSize(); // create and initialize a Label - this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, TextHAlignment::CENTER); - this->_labelShouldRetain->retain(); + _labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, TextHAlignment::CENTER); + _labelShouldRetain->retain(); - this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); - this->_arrowsBarShouldRetain->retain(); - this->_arrowsShouldRetain = Sprite::create("Images/arrows.png"); - this->_arrowsShouldRetain->retain(); + _arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); + _arrowsBarShouldRetain->retain(); + _arrowsShouldRetain = Sprite::create("Images/arrows.png"); + _arrowsShouldRetain->retain(); MenuItemFont::setFontSize(20); auto longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); @@ -1199,24 +1206,24 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() right->setTag(RightAlign); // 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; - this->_arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width); - this->_arrowsBarShouldRetain->setPosition(Point(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); + _arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width); + _arrowsBarShouldRetain->setPosition(Point(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y)); this->snapArrowsToEdge(); stringMenu->setPosition(Point(size.width/2, size.height - menuItemPaddingCenter)); alignmentMenu->setPosition(Point(size.width/2, menuItemPaddingCenter+15)); - this->addChild(this->_labelShouldRetain); - this->addChild(this->_arrowsBarShouldRetain); - this->addChild(this->_arrowsShouldRetain); - this->addChild(stringMenu); - this->addChild(alignmentMenu); + addChild(_labelShouldRetain); + addChild(_arrowsBarShouldRetain); + addChild(_arrowsShouldRetain); + addChild(stringMenu); + addChild(alignmentMenu); } BitmapFontMultiLineAlignment::~BitmapFontMultiLineAlignment() @@ -1246,13 +1253,13 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Ref *sender) switch(item->getTag()) { case LongSentences: - this->_labelShouldRetain->setString(LongSentencesExample); + static_cast(_labelShouldRetain)->setString(LongSentencesExample); break; case LineBreaks: - this->_labelShouldRetain->setString(LineBreaksExample); + static_cast(_labelShouldRetain)->setString(LineBreaksExample); break; case Mixed: - this->_labelShouldRetain->setString(MixedExample); + static_cast(_labelShouldRetain)->setString(MixedExample); break; default: @@ -1272,13 +1279,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Ref *sender) switch(item->getTag()) { case LeftAlign: - this->_labelShouldRetain->setAlignment(TextHAlignment::LEFT); + static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::LEFT); break; case CenterAlign: - this->_labelShouldRetain->setAlignment(TextHAlignment::CENTER); + static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::CENTER); break; case RightAlign: - this->_labelShouldRetain->setAlignment(TextHAlignment::RIGHT); + static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::RIGHT); break; default: @@ -1325,7 +1332,7 @@ void BitmapFontMultiLineAlignment::onTouchesMoved(const std::vector& tou float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2; - this->_labelShouldRetain->setWidth(labelWidth); + static_cast(_labelShouldRetain)->setWidth(labelWidth); } void BitmapFontMultiLineAlignment::snapArrowsToEdge() @@ -1736,3 +1743,9 @@ std::string LabelBMFontBinaryFormat::subtitle() const { 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 diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.h b/tests/cpp-tests/Classes/LabelTest/LabelTest.h index e0015b027b..48adc7c8f8 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.h @@ -235,8 +235,8 @@ private: void updateAlignment(); const char* getCurrentAlignment(); private: - LabelTTF* _plabel; TextHAlignment _horizAlign; + Node* _label; TextVAlignment _vertAlign; }; @@ -285,7 +285,7 @@ public: void onTouchesMoved(const std::vector& touches, Event *event); public: - LabelBMFont *_labelShouldRetain; + Node *_labelShouldRetain; Sprite *_arrowsBarShouldRetain; Sprite *_arrowsShouldRetain; MenuItemFont *_lastSentenceItem, *_lastAlignmentItem; @@ -383,7 +383,7 @@ public: protected: void onDraw(const kmMat4 &transform, bool transformUpdated); private: - LabelBMFont *label1; + Node *label1; CustomCommand _customCommand; }; From 51f3833a7eb617bc399849c5d4cca0d678060360 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 31 Mar 2014 17:31:04 +0800 Subject: [PATCH 3/6] fixed warn. --- tests/cpp-tests/Classes/LabelTest/LabelTest.cpp | 12 ++++++------ tests/cpp-tests/Classes/LabelTest/LabelTest.h | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 0c637c275f..9f7a3f8f95 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -1253,13 +1253,13 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Ref *sender) switch(item->getTag()) { case LongSentences: - static_cast(_labelShouldRetain)->setString(LongSentencesExample); + _labelShouldRetain->setString(LongSentencesExample); break; case LineBreaks: - static_cast(_labelShouldRetain)->setString(LineBreaksExample); + _labelShouldRetain->setString(LineBreaksExample); break; case Mixed: - static_cast(_labelShouldRetain)->setString(MixedExample); + _labelShouldRetain->setString(MixedExample); break; default: @@ -1279,13 +1279,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Ref *sender) switch(item->getTag()) { case LeftAlign: - static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::LEFT); + _labelShouldRetain->setAlignment(TextHAlignment::LEFT); break; case CenterAlign: - static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::CENTER); + _labelShouldRetain->setAlignment(TextHAlignment::CENTER); break; case RightAlign: - static_cast(_labelShouldRetain)->setAlignment(TextHAlignment::RIGHT); + _labelShouldRetain->setAlignment(TextHAlignment::RIGHT); break; default: diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.h b/tests/cpp-tests/Classes/LabelTest/LabelTest.h index 48adc7c8f8..dc596eef0f 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.h @@ -4,6 +4,12 @@ #include "../testBasic.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 { @@ -236,7 +242,7 @@ private: const char* getCurrentAlignment(); private: TextHAlignment _horizAlign; - Node* _label; + LabelTTF* _label; TextVAlignment _vertAlign; }; @@ -285,7 +291,7 @@ public: void onTouchesMoved(const std::vector& touches, Event *event); public: - Node *_labelShouldRetain; + LabelBMFont *_labelShouldRetain; Sprite *_arrowsBarShouldRetain; Sprite *_arrowsShouldRetain; MenuItemFont *_lastSentenceItem, *_lastAlignmentItem; @@ -383,7 +389,7 @@ public: protected: void onDraw(const kmMat4 &transform, bool transformUpdated); private: - Node *label1; + LabelBMFont *label1; CustomCommand _customCommand; }; @@ -445,6 +451,11 @@ public: 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 From 687b2e9f875ceb915b2dda3fc6e9670fabce9ce3 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 31 Mar 2014 17:38:54 +0800 Subject: [PATCH 4/6] update test case. --- .../cpp-tests/Classes/LabelTest/LabelTest.cpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 9f7a3f8f95..2b1d00ced5 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -359,19 +359,19 @@ LabelTTFAlignment::LabelTTFAlignment() Size(256, 32), TextHAlignment::LEFT); 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); auto ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::CENTER); 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); auto ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::RIGHT); 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); } @@ -405,11 +405,11 @@ Atlas3::Atlas3() auto label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label1->setAnchorPoint( Point(0,0) ); + label1->setAnchorPoint( Point::ANCHOR_BOTTOM_LEFT ); addChild(label1, 0, kTagBitmapAtlas1); auto fade = FadeOut::create(1.0f); 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); label1->runAction(repeat); @@ -420,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 auto label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label2->setAnchorPoint( Point(0.5f, 0.5f) ); + label2->setAnchorPoint( Point::ANCHOR_MIDDLE ); label2->setColor( Color3B::RED ); addChild(label2, 0, kTagBitmapAtlas2); auto tint = Sequence::create(TintTo::create(1, 255, 0, 0), @@ -431,7 +431,7 @@ Atlas3::Atlas3() auto label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors - label3->setAnchorPoint( Point(1,1) ); + label3->setAnchorPoint( Point::ANCHOR_TOP_RIGHT ); addChild(label3, 0, kTagBitmapAtlas3); label1->setPosition( VisibleRect::leftBottom() ); @@ -491,7 +491,7 @@ Atlas4::Atlas4() auto s = Director::getInstance()->getWinSize(); 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); @@ -593,7 +593,7 @@ Atlas5::Atlas5() auto s = Director::getInstance()->getWinSize(); 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 @@ -625,17 +625,17 @@ Atlas6::Atlas6() label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); addChild(label); 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"); addChild(label); 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"); addChild(label); 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 @@ -663,23 +663,23 @@ AtlasBitmapColor::AtlasBitmapColor() { auto s = Director::getInstance()->getWinSize(); - LabelBMFont* label = NULL; + LabelBMFont* label = nullptr; label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt"); label->setColor( Color3B::BLUE ); addChild(label); 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"); addChild(label); 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 = LabelBMFont::create("G", "fonts/bitmapFontTest5.fnt"); addChild(label); 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->setString("Green"); } @@ -720,7 +720,7 @@ AtlasFastBitmap::AtlasFastBitmap() auto p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); label->setPosition( p ); - label->setAnchorPoint(Point(0.5f, 0.5f)); + label->setAnchorPoint(Point::ANCHOR_MIDDLE); } } @@ -751,7 +751,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Left 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); s = label1->getContentSize(); @@ -760,7 +760,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Center 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); s= label2->getContentSize(); @@ -768,7 +768,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // right 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); s = label3->getContentSize(); @@ -888,7 +888,7 @@ LabelAtlasHD::LabelAtlasHD() // LabelBMFont 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); label1->setPosition(Point(s.width/2, s.height/2)); @@ -952,7 +952,7 @@ LabelTTFTest::LabelTTFTest() auto s = Director::getInstance()->getWinSize(); 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)); this->addChild(colorLayer); @@ -1004,7 +1004,7 @@ void LabelTTFTest::updateAlignment() blockSize, _horizAlign, _vertAlign); _label->retain(); - _label->setAnchorPoint(Point(0,0)); + _label->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT); _label->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); this->addChild(_label); @@ -1332,7 +1332,7 @@ void BitmapFontMultiLineAlignment::onTouchesMoved(const std::vector& tou float labelWidth = fabs(this->_arrowsShouldRetain->getPosition().x - this->_labelShouldRetain->getPosition().x) * 2; - static_cast(_labelShouldRetain)->setWidth(labelWidth); + _labelShouldRetain->setWidth(labelWidth); } void BitmapFontMultiLineAlignment::snapArrowsToEdge() From 9801dc6f50bfc0982d3df8702233f250fe3c080f Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 31 Mar 2014 09:52:30 +0000 Subject: [PATCH 5/6] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index 5f93e99c32..04442610ae 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -cc2b5203a3684cb44db1ecc7b1e3423e070a993f \ No newline at end of file +52a0d8b07b35e82b9c74faacb9c5437fe7396663 \ No newline at end of file From f485d3b6d5ae77be8f1502370236125f5854986c Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 31 Mar 2014 18:16:08 +0800 Subject: [PATCH 6/6] Label:fixed possible blink if label contains shadow. --- cocos/2d/CCLabel.cpp | 86 ++++++++++++++++++++------------------------ cocos/2d/CCLabel.h | 3 +- 2 files changed, 40 insertions(+), 49 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 9f9a35be6e..435e01d4b2 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -279,6 +279,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te , _currNumLines(-1) , _textSprite(nullptr) , _contentDirty(false) +, _shadowDirty(false) { setAnchorPoint(Point::ANCHOR_MIDDLE); reset(); @@ -852,6 +853,7 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const { _shadowEnabled = true; _fontDefinition._shadow._shadowEnabled = false; + _shadowDirty = true; _effectColor = shadowColor; _effectColorF.r = _effectColor.r / 255.0f; @@ -928,13 +930,11 @@ void Label::onDraw(const kmMat4& transform, bool transformUpdated) } else if(_shadowEnabled && _shadowBlurRadius <= 0) { - trans = true; - kmGLPushMatrix(); drawShadowWithoutBlur(); } _shaderProgram->setUniformsForBuiltins(transform); - + for(const auto &child: _children) { if(child->getTag() >= 0) @@ -946,29 +946,17 @@ void Label::onDraw(const kmMat4& transform, bool transformUpdated) batchNode->getTextureAtlas()->drawQuads(); } - if (trans) - { - kmGLPopMatrix(); - } - CC_PROFILER_STOP("Label - draw"); } void Label::drawShadowWithoutBlur() { - _position.x += _shadowOffset.width; - _position.y += _shadowOffset.height; - _transformDirty = _inverseDirty = true; - Color3B oldColor = _realColor; GLubyte oldOPacity = _displayedOpacity; _displayedOpacity = _effectColorF.a * _displayedOpacity; setColor(_shadowColor); - _modelViewTransform = transform(_parentTransform); - kmGLLoadMatrix(&_modelViewTransform); - - _shaderProgram->setUniformsForBuiltins(_modelViewTransform); + _shaderProgram->setUniformsForBuiltins(_shadowTransform); for(const auto &child: _children) { child->updateTransform(); @@ -978,15 +966,8 @@ void Label::drawShadowWithoutBlur() batchNode->getTextureAtlas()->drawQuads(); } - _position.x -= _shadowOffset.width; - _position.y -= _shadowOffset.height; - _transformDirty = _inverseDirty = true; - _displayedOpacity = oldOPacity; setColor(oldColor); - - _modelViewTransform = transform(_parentTransform); - kmGLLoadMatrix(&_modelViewTransform); } 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(); } - if (! _textSprite && _shadowEnabled && _shadowBlurRadius <= 0) + bool dirty = parentTransformUpdated || _transformUpdated; + + if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty)) { - _parentTransform = parentTransform; - draw(renderer, _modelViewTransform, true); + _position.x += _shadowOffset.width; + _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 { - bool dirty = parentTransformUpdated || _transformUpdated; - - 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(); + draw(renderer, _modelViewTransform, dirty); } + + kmGLPopMatrix(); setOrderOfArrival(0); } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 12750f8a39..16fce93ec8 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -368,10 +368,11 @@ protected: GLuint _uniformTextColor; CustomCommand _customCommand; + bool _shadowDirty; bool _shadowEnabled; Size _shadowOffset; int _shadowBlurRadius; - kmMat4 _parentTransform; + kmMat4 _shadowTransform; Color3B _shadowColor; Sprite* _shadowNode;