Node* node = CSLoader::createNode("home.csb"); this->addChild(node); Button* btnPlay = dynamic_cast<Button*>(node ->getChildByName("btnPlay")); Button* btnPlay = static_cast<ui::Button*>(Helper::seekWidgetByName(node, "btnPlay")); btnPlay ->addClickEventListener(CC_CALLBACK_1(XXX::onPlay, this)); btnPlay->addTouchEventListener(CC_CALLBACK_2(XXX::onPlay, this)); void XXX::onPlay(Ref *pSender, Widget::TouchEventType type) { switch (type) { case Widget::TouchEventType::BEGAN: break; case Widget::TouchEventType::MOVED: break; case Widget::TouchEventType::ENDED: break; case Widget::TouchEventType::CANCELED: break; default: break; } } void XXX::onPlay(Ref* sender) { }
时间: 2024-10-29 02:51:46