bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
Size size=Director::getInstance()->getVisibleSize();
auto label=LabelTTF::create("Click me","Courier",30);
label->setPosition(size.width/2,size.height/2);
addChild(label);
auto listener=EventListenerTouchOneByOne::create();
listener->onTouchBegan=[](Touch *t,Event *e){
if (e->getCurrentTarget()->getBoundingBox().containsPoint(t->getLocation())) {
log("OnTouchBegan");
}
return false;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,label);
return true;
}