MCPcopy Create free account
hub / github.com/axmolengine/axmol / onEnter

Method onEnter

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:1674–1737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1672LabelShadowTest::LabelShadowTest() {}
1673
1674void LabelShadowTest::onEnter()
1675{
1676 AtlasDemoNew::onEnter();
1677
1678 auto size = Director::getInstance()->getWinSize();
1679
1680 auto bg = LayerColor::create(Color4B(200, 191, 231, 255));
1681 this->addChild(bg);
1682
1683 auto slider = ui::Slider::create();
1684 slider->setTag(1);
1685 slider->setTouchEnabled(true);
1686 slider->loadBarTexture("cocosui/sliderTrack.png");
1687 slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
1688 slider->loadProgressBarTexture("cocosui/sliderProgress.png");
1689 slider->setPosition(Vec2(size.width / 2.0f, size.height * 0.15f + slider->getContentSize().height * 2.0f));
1690 slider->setPercent(52);
1691 slider->addEventListener(AX_CALLBACK_2(LabelShadowTest::sliderEvent, this));
1692 addChild(slider, 999);
1693
1694 auto slider2 = ui::Slider::create();
1695 slider2->setTag(2);
1696 slider2->setTouchEnabled(true);
1697 slider2->loadBarTexture("cocosui/sliderTrack.png");
1698 slider2->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
1699 slider2->loadProgressBarTexture("cocosui/sliderProgress.png");
1700 slider2->setPosition(Vec2(size.width * 0.15f, size.height / 2.0f));
1701 slider2->setRotation(90);
1702 slider2->setPercent(52);
1703 slider2->addEventListener(AX_CALLBACK_2(LabelShadowTest::sliderEvent, this));
1704 addChild(slider2, 999);
1705
1706 float subtitleY = _subtitleLabel->getPosition().y;
1707 float horizontalSliderY = slider->getPosition().y;
1708 float step = (subtitleY - horizontalSliderY) / 4;
1709
1710 TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC, nullptr, true);
1711
1712 shadowLabelTTF = Label::createWithTTF(ttfConfig, "TTF:Shadow");
1713 shadowLabelTTF->setPosition(Vec2(size.width / 2, horizontalSliderY + step * (0.5f + 3)));
1714 shadowLabelTTF->setTextColor(Color4B::RED);
1715 shadowLabelTTF->enableShadow(Color4B::BLACK);
1716 addChild(shadowLabelTTF);
1717
1718 shadowLabelOutline = Label::createWithTTF(ttfConfig, "TTF:Shadow");
1719 shadowLabelOutline->setPosition(Vec2(size.width / 2, horizontalSliderY + step * (0.5f + 2)));
1720 shadowLabelOutline->setTextColor(Color4B::RED);
1721 shadowLabelOutline->enableOutline(Color4B::YELLOW, 1);
1722 shadowLabelOutline->enableShadow(Color4B::GREEN);
1723 addChild(shadowLabelOutline);
1724
1725 shadowLabelGrow = Label::createWithTTF(ttfConfig, "TTF:Shadow");
1726 shadowLabelGrow->setPosition(Vec2(size.width / 2, horizontalSliderY + step * (0.5f + 1)));
1727 shadowLabelGrow->setTextColor(Color4B::RED);
1728 shadowLabelGrow->enableGlow(Color4B::YELLOW);
1729 shadowLabelGrow->enableShadow(Color4B::BLUE);
1730 addChild(shadowLabelGrow);
1731

Callers

nothing calls this directly

Calls 15

getInstanceFunction · 0.85
createFunction · 0.85
Color4BFunction · 0.85
setTagMethod · 0.80
loadBarTextureMethod · 0.80
loadSlidBallTexturesMethod · 0.80
Vec2Function · 0.50
addChildMethod · 0.45
setTouchEnabledMethod · 0.45
setPositionMethod · 0.45
getContentSizeMethod · 0.45

Tested by

no test coverage detected