onButton控件的:
Button* btn = (Button*)f; auto ss = (Widget*)btn->getParent()->getParent(); auto aa = (TextField*)ss->getChildByName("TextField"); if (type == TouchEventType::TOUCH_EVENT_ENDED) { CCLOG("---------------------ON -------------------"); } if (type == TouchEventType::TOUCH_EVENT_BEGAN) { CCLOG("---------------------began -------------------"); aa->setText("Place Name"); }CheckBox控件
CheckBox* cb = (CheckBox*)f; Widget* wd = (Widget*)cb->getParent(); auto ss = (ImageView*)wd->getChildByName("Image_4"); if (type == CheckBoxEventType::CHECKBox_STATE_EVENT_SELECTED) { CCLOG("-----CheckBox--BEGAN--"); ss->setVisible(true); } if (type == CheckBoxEventType::CHECKBox_STATE_EVENT_UNSELECTED) { CCLOG("-----CheckBox--ENDED--"); ss->setVisible(false); }未完,待续..... 原文链接:https://www.f2er.com/cocos2dx/346208.html