简单记录一下2dx的鼠标交互事件。以及精灵绑定盒的点击判定
Layer 子类的 init方法中:
auto listener = EventListenerTouchOneByOne::create();// listener->onTouchBegan = CC_CALLBACK_2(GameMenuScene::touchBegin,this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
Layer子类源文件中:
bool GameMenuScene::touchBegin(CCTouch * touch,CCEvent *event) { CCPoint pt = touch->getLocationInView(); pt = Director::getInstance()->convertToGL(pt); if(sprite->getBoundingBox().containsPoint(pt)) { CCLog("CLick"); } return true; }