@ridincal 写道:
在场景中添加了若干个按钮和鼠标事件监听器,如何判断用户点击的是哪个按钮啊,这样为何不行啊:
auto mouseListener = EventListenerMouse::create(); mouseListener->onMouseDown = [=](Event *event) { ui::Button* bt = static_cast<ui::Button*>(event->getCurrentTarget()); int tag = bt->getTag(); switch (tag) { case Btn_TAG1: { break; } case Btn_TAG2: { break; } default: break; } } _eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);
帖子: 1
参与者: 1