cocos2d-x给Text,imageView添加侦听

来源:互联网 发布:ajax 异步获取数据 编辑:程序博客网 时间:2024/06/05 15:14

其实很简单,跟button一样的。

auto Text_cancelcreate = static_cast<Text*>(m_ClubLayer[Panel_ccreateclub]->getChildByName("TextField_14cancel"));
Text_cancelcreate->addTouchEventListener(CC_CALLBACK_2(PageClubLayer::onCreateClubBtn, this));
auto Image_clubhead = static_cast<ImageView*>(m_ClubLayer[Panel_ccreateclub]->getChildByName("Image_clubhead"));
Image_clubhead->addTouchEventListener(CC_CALLBACK_2(PageClubLayer::onCreateClubBtn, this));


void PageClubLayer::onCreateClubBtn(Ref* pSender, Widget::TouchEventType eType){
if (eType == Widget::TouchEventType::ENDED)
{
Node* pNode = (Node*)pSender;
std::string sname = pNode->getName();
if (sname == "TextField_14cancel"){
this->openClubPage(Panel_cnoclub);
}
else if (sname == "Image_clubhead"){
//open camera
}
}
}     

0 0
原创粉丝点击