Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

3.x中事件分发器问题

$
0
0

@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

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>