代码:
auto touchListener = EventListenerTouchOneByOne::create();touchListener->onTouchBegan = &](Touch* t,Event* e){ log("Begin!!!"); auto touchLocation = t->getLocation(); s->setPosition(touchLocation); return true; }; touchListener->onTouchMoved = &](Touch* t,Event* e){ log("Moved!!!!!!"); }; _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener,this);<p> </p> 点击之后没有log输出。<p></p> <p>而去创建时的menu菜单也无法点击,刚开始能点击 之后就不能点击了,代码是没有问题的 ,重新建一个项目用同样的代码 就能用了,不过我不可能每次都这样吧?</p> <p>下面是Physics的碰撞检测 也是一点没有log输出</p> <p></p> <pre class="""""brush:cpp;"""" toolbar:="""""""" true;="""""""" auto-links:="""""""" false;"="""""""">auto contact = EventListenerPhysicsContact::create(); contact->onContactBegin = &](const PhysicsContact& contact){ log(">>>>>>>>>>>>>"); auto spriteA =(Sprite*) contact.getShapeA()->getBody()->getNode(); auto spriteB =(Sprite*) contact.getShapeB()->getBody()->getNode(); if(spriteA->getTag() == 1){ spriteA->removeFromParentAndCleanup(true); }else if(spriteB->getTag() == 1) { spriteB->removeFromParentAndCleanup(true); } return false; }; this->_eventDispatcher->addEventListenerWithSceneGraphPriority(contact,this);