本文整理汇总了C++中ListView::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ListView::setAnchorPoint方法的具体用法?C++ ListView::setAnchorPoint怎么用?C++ ListView::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListView
的用法示例。
在下文中一共展示了ListView::setAnchorPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//-------------------------------------------
bool DialogView::init(const std::string& strTitle, const std::string& strContent)
{
if (!Node::init())
return false;
Size winSize = Director::getInstance()->getWinSize();
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
// 截断事件传递
EventListenerTouchOneByOne* eve = EventListenerTouchOneByOne::create();
eve->setSwallowTouches(true);
eve->onTouchBegan = [](Touch* t, Event* e)
{
return true;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(eve, this);
// 背景
Sprite* pPlane = Sprite::create(RES::DIALOG_PLANE);
pPlane->setPosition(origin + visibleSize / 2);
this->addChild(pPlane);
// 确认按钮
Button* pBtnOK = Button::create(RES::DIALOG_OK);
pBtnOK->setPosition(Vec2(pPlane->getContentSize().width / 2, 0));
pBtnOK->addClickEventListener([=](Ref* pS)
{
if (onOkButtonClick)
onOkButtonClick(this);
});
pPlane->addChild(pBtnOK);
// 标题
Text* pTextTitle = Text::create(strTitle, "", 32);
pTextTitle->setPosition(Vec2(pPlane->getContentSize().width / 2, pPlane->getContentSize().height - 28));
pPlane->addChild(pTextTitle);
// 内容List
ListView* pListView = ListView::create();
pListView->setAnchorPoint(Vec2(0.5, 0.5));
pListView->setPosition(Vec2(pPlane->getContentSize().width/2, 146));
pListView->setContentSize(Size(pPlane->getContentSize().width - 60, 210));
pListView->setBounceEnabled(true);
pPlane->addChild(pListView);
// 内容Text
Text* pTextContent = Text::create(strContent, "", 26);
pTextContent->setTextHorizontalAlignment(TextHAlignment::CENTER);
pTextContent->setTextAreaSize(Size(pListView->getContentSize().width, 0));
pTextContent->ignoreContentAdaptWithSize(false);
pListView->pushBackCustomItem(pTextContent);
// 播放动画
pPlane->setScaleX(0);
pPlane->setScaleY(0.5);
ScaleTo* pActionScale = ScaleTo::create(0.35, 1);
pPlane->runAction(EaseBackOut::create(pActionScale));
return true;
}