本文整理汇总了C++中PageView::addEventListenerPageView方法的典型用法代码示例。如果您正苦于以下问题:C++ PageView::addEventListenerPageView方法的具体用法?C++ PageView::addEventListenerPageView怎么用?C++ PageView::addEventListenerPageView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageView
的用法示例。
在下文中一共展示了PageView::addEventListenerPageView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PageInit
void CocosGUIExamplesPageScene::PageInit()
{
// page root from json
Layout* page_root = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosgui/gui_examples/page_1/page_1.json"));
m_pUILayer->addWidget(page_root);
// page layout
Layout* page_layout = dynamic_cast<Layout*>(page_root->getChildByName("page_panel"));
// page view add to page layout
PageView* pageView = PageView::create();
pageView->setTouchEnabled(true);
pageView->setSize(page_layout->getSize());
// layout add to page view
for (int i = 0; i < 4; ++i)
{
Layout* layout = Layout::create();
layout->setSize(pageView->getSize());
ImageView* imageView = ImageView::create();
imageView->setTouchEnabled(true);
imageView->loadTexture(page_image_textures[i]);
imageView->setPosition(ccp(layout->getSize().width / 2, layout->getSize().height / 2));
layout->addChild(imageView);
pageView->addPage(layout);
}
pageView->addEventListenerPageView(this, pagevieweventselector(CocosGUIExamplesPageScene::pageViewEvent));
page_layout->addChild(pageView);
}
示例2: init
bool UIPageViewTest::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getSize();
// Add a label in which the dragpanel events will be displayed
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f +
_displayValueLabel->getContentSize().height * 1.5));
_uiLayer->addChild(_displayValueLabel);
// Add the black background
Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
_uiLayer->addChild(alert);
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
// Create the page view
PageView* pageView = PageView::create();
pageView->setSize(Size(240.0f, 130.0f));
Size backgroundSize = background->getContentSize();
pageView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
(backgroundSize.width - pageView->getSize().width) / 2.0f,
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - pageView->getSize().height) / 2.0f));
for (int i = 0; i < 3; ++i)
{
Layout* layout = Layout::create();
layout->setSize(Size(240.0f, 130.0f));
ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
imageView->setScale9Enabled(true);
imageView->setSize(Size(240, 130));
imageView->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(imageView);
Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
label->setColor(Color3B(192, 192, 192));
label->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
layout->addChild(label);
pageView->addPage(layout);
}
pageView->addEventListenerPageView(this, pagevieweventselector(UIPageViewTest::pageViewEvent));
_uiLayer->addChild(pageView);
return true;
}
return false;
}
示例3: pagevieweventselector
static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L)
{
if (nullptr == L)
return 0;
int argc = 0;
PageView* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<PageView*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListenerPageView'\n", NULL);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (1 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) )
{
goto tolua_lerror;
}
#endif
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
if (nullptr == listener)
{
tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
return 0;
}
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
self->setUserObject(listener);
self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0;
}
CCLOG("'addEventListenerPageView' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err);
return 0;
#endif
}
示例4: pagevieweventselector
static int tolua_Cocos2dx_PageView_addEventListenerPageView00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"PageView",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
PageView* self = (PageView*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addEventListenerPageView'", NULL);
#endif
LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create();
if (NULL == listener)
{
tolua_error(tolua_S,"LuaCocoStudioEventListener create fail\n", NULL);
return 0;
}
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
listener->setHandler(handler);
CCDictionary* dict = static_cast<CCDictionary*>(self->getScriptObjectDict());
if (NULL == dict)
{
dict = CCDictionary::create();
self->setScriptObjectDict(dict);
}
dict->setObject(listener, "pageViewEventListener");
self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'addEventListenerPageView'.",&tolua_err);
return 0;
#endif
}