mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1 from Pisces000221/patch-8
Will merge this pull request
This commit is contained in:
commit
7f19e2ad7e
|
@ -63,6 +63,7 @@ static std::function<Layer*()> createFunctions[] =
|
||||||
CL(LabelTTFColor),
|
CL(LabelTTFColor),
|
||||||
CL(LabelTTFFontsTestNew),
|
CL(LabelTTFFontsTestNew),
|
||||||
CL(LabelTTFDynamicAlignment),
|
CL(LabelTTFDynamicAlignment),
|
||||||
|
CL(LabelTTFCJKWrappingTest),
|
||||||
CL(LabelTTFUnicodeNew),
|
CL(LabelTTFUnicodeNew),
|
||||||
CL(LabelBMFontTestNew),
|
CL(LabelBMFontTestNew),
|
||||||
CL(LabelTTFDistanceField),
|
CL(LabelTTFDistanceField),
|
||||||
|
@ -1071,6 +1072,56 @@ std::string LabelTTFDynamicAlignment::subtitle() const
|
||||||
return "Uses the new Label with TTF. Testing alignment";
|
return "Uses the new Label with TTF. Testing alignment";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// NewLabelTTF Chinese/Japanese/Korean wrapping test
|
||||||
|
//
|
||||||
|
LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest()
|
||||||
|
{
|
||||||
|
auto size = Director::getInstance()->getWinSize();
|
||||||
|
|
||||||
|
auto drawNode = DrawNode::create();
|
||||||
|
drawNode->setAnchorPoint(Point(0, 0));
|
||||||
|
this->addChild(drawNode);
|
||||||
|
drawNode->drawSegment(
|
||||||
|
Point(size.width * 0.1, size.height * 0.8),
|
||||||
|
Point(size.width * 0.1, 0), 1, Color4F(1, 0, 0, 1));
|
||||||
|
drawNode->drawSegment(
|
||||||
|
Point(size.width * 0.85, size.height * 0.8),
|
||||||
|
Point(size.width * 0.85, 0), 1, Color4F(1, 0, 0, 1));
|
||||||
|
|
||||||
|
TTFConfig ttfConfig("fonts/wt021.ttf", 50, GlyphCollection::DYNAMIC);
|
||||||
|
auto label1 = Label::createWithTTF(ttfConfig,
|
||||||
|
"你好,Cocos2d-x v3的New Label。", TextHAlignment::LEFT, size.width * 0.75);
|
||||||
|
label1->setColor(Color3B(128, 255, 255));
|
||||||
|
label1->setPosition(Point(size.width * 0.1, size.height * 0.6));
|
||||||
|
label1->setAnchorPoint(Point(0, 0.5));
|
||||||
|
this->addChild(label1);
|
||||||
|
|
||||||
|
auto label2 = Label::createWithTTF(ttfConfig,
|
||||||
|
"早上好,Cocos2d-x v3的New Label。", TextHAlignment::LEFT, size.width * 0.75);
|
||||||
|
label2->setColor(Color3B(255, 128, 255));
|
||||||
|
label2->setPosition(Point(size.width * 0.1, size.height * 0.4));
|
||||||
|
label2->setAnchorPoint(Point(0, 0.5));
|
||||||
|
this->addChild(label2);
|
||||||
|
auto label3 = Label::createWithTTF(ttfConfig,
|
||||||
|
"美好的一天啊美好的一天啊美好的一天啊", TextHAlignment::LEFT, size.width * 0.75);
|
||||||
|
label3->setColor(Color3B(255, 255, 128));
|
||||||
|
label3->setPosition(Point(size.width * 0.1, size.height * 0.2));
|
||||||
|
label3->setAnchorPoint(Point(0, 0.5));
|
||||||
|
this->addChild(label3);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelTTFCJKWrappingTest::title() const
|
||||||
|
{
|
||||||
|
return "New Label + .TTF";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelTTFCJKWrappingTest::subtitle() const
|
||||||
|
{
|
||||||
|
return "New Label with CJK + ASCII characters\n"
|
||||||
|
"Characters should stay in the correct position";
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// NewLabelTTF unicode test
|
// NewLabelTTF unicode test
|
||||||
//
|
//
|
||||||
|
|
|
@ -287,6 +287,19 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class LabelTTFCJKWrappingTest : public AtlasDemoNew
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(LabelTTFCJKWrappingTest);
|
||||||
|
|
||||||
|
LabelTTFCJKWrappingTest();
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class LabelTTFFontsTestNew : public AtlasDemoNew
|
class LabelTTFFontsTestNew : public AtlasDemoNew
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1008,6 +1008,64 @@ function LabelTTFDynamicAlignment.setAlignmentRight(pSender)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------
|
||||||
|
----- LabelTTFCJKWrappingTest
|
||||||
|
--------------------------------------------------------
|
||||||
|
local LabelTTFCJKWrappingTest = {}
|
||||||
|
function LabelTTFCJKWrappingTest.create()
|
||||||
|
local layer = cc.Layer:create()
|
||||||
|
Helper.initWithLayer(layer)
|
||||||
|
Helper.titleLabel:setString("New Label + .TTF")
|
||||||
|
Helper.subtitleLabel:setString(
|
||||||
|
"New Label with CJK + ASCII characters\n"
|
||||||
|
.. "Characters should stay in the correct position")
|
||||||
|
|
||||||
|
local size = cc.Director:getInstance():getVisibleSize()
|
||||||
|
local ttfConfig = {}
|
||||||
|
ttfConfig.fontFilePath = "fonts/wt021.ttf"
|
||||||
|
ttfConfig.fontSize = 50
|
||||||
|
ttfConfig.glyphs = cc.GLYPHCOLLECTION_DYNAMIC
|
||||||
|
ttfConfig.customGlyphs = nil
|
||||||
|
ttfConfig.distanceFieldEnabled = true
|
||||||
|
|
||||||
|
local drawNode = cc.DrawNode:create()
|
||||||
|
drawNode:setAnchorPoint(cc.p(0, 0))
|
||||||
|
layer:addChild(drawNode)
|
||||||
|
drawNode:drawSegment(
|
||||||
|
cc.p(size.width * 0.1, size.height * 0.8),
|
||||||
|
cc.p(size.width * 0.1, 0), 1, cc.c4f(1, 0, 0, 1))
|
||||||
|
drawNode:drawSegment(
|
||||||
|
cc.p(size.width * 0.85, size.height * 0.8),
|
||||||
|
cc.p(size.width * 0.85, 0), 1, cc.c4f(1, 0, 0, 1))
|
||||||
|
|
||||||
|
local label1 = cc.Label:createWithTTF(
|
||||||
|
ttfConfig, "你好,Cocos2d-x v3的New Label。",
|
||||||
|
cc.TEXT_ALIGNMENT_LEFT, size.width * 0.75)
|
||||||
|
label1:setColor(cc.c3b(128, 255, 255))
|
||||||
|
label1:setPosition(cc.p(size.width * 0.1, size.height * 0.6))
|
||||||
|
label1:setAnchorPoint(cc.p(0, 0.5))
|
||||||
|
layer:addChild(label1)
|
||||||
|
|
||||||
|
local label2 = cc.Label:createWithTTF(
|
||||||
|
ttfConfig, "早上好,Cocos2d-x v3的New Label。",
|
||||||
|
cc.TEXT_ALIGNMENT_LEFT, size.width * 0.75)
|
||||||
|
label2:setColor(cc.c3b(255, 128, 255))
|
||||||
|
label2:setPosition(cc.p(size.width * 0.1, size.height * 0.4))
|
||||||
|
label2:setAnchorPoint(cc.p(0, 0.5))
|
||||||
|
layer:addChild(label2)
|
||||||
|
|
||||||
|
local label3 = cc.Label:createWithTTF(
|
||||||
|
ttfConfig, "美好的一天啊美好的一天啊美好的一天啊",
|
||||||
|
cc.TEXT_ALIGNMENT_LEFT, size.width * 0.75)
|
||||||
|
label3:setColor(cc.c3b(255, 255, 128))
|
||||||
|
label3:setPosition(cc.p(size.width * 0.1, size.height * 0.2))
|
||||||
|
label3:setAnchorPoint(cc.p(0, 0.5))
|
||||||
|
layer:addChild(label3)
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
----- LabelTTFFontsTestNew
|
----- LabelTTFFontsTestNew
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
|
@ -1262,6 +1320,7 @@ function LabelTestNew()
|
||||||
LabelFNTBounds.create,
|
LabelFNTBounds.create,
|
||||||
LabelTTFLongLineWrapping.create,
|
LabelTTFLongLineWrapping.create,
|
||||||
LabelTTFDynamicAlignment.create,
|
LabelTTFDynamicAlignment.create,
|
||||||
|
LabelTTFCJKWrappingTest.create,
|
||||||
LabelTTFFontsTestNew.create,
|
LabelTTFFontsTestNew.create,
|
||||||
LabelBMFontTestNew.create,
|
LabelBMFontTestNew.create,
|
||||||
LabelTTFDistanceField.create,
|
LabelTTFDistanceField.create,
|
||||||
|
|
Loading…
Reference in New Issue