bool init()
{ ……………….
//注册触摸事件
// setTouchEnabled(true);
// setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
EventListenerTouchOneByOne *eventTouch = EventListenerTouchOneByOne::create();
eventTouch->onTouchBegan = CC_CALLBACK_2(SceneStart::onTouchBegan, this);
eventTouch->onTouchEnded = CC_CALLBACK_2(SceneStart::onTouchEnded, this);
//注册事件对象
EventDispatcher* dispatcher = Director::getInstance()->getEventDispatcher();
eventTouch->setSwallowTouches(true);//不向下传递触摸
dispatcher->addEventListenerWithSceneGraphPriority(eventTouch, this);
return true;
}
bool SceneStart::onTouchBegan(Touch* pTouch, Event* pEvent)
{
return true;
}
void SceneStart::onTouchEnded(Touch* pTouch, Event* pEvent)
{ }