bool MenuMove::init()
{
if (!Layer::init()) {
return false;
}
menu=Sprite::create("CloseSelected.png");
menu->setPosition(Vec2::ZERO);
menu->setAnchorPoint(Vec2(180,180));
addChild(menu);
auto dis=Director::getInstance()->getEventDispatcher();
auto lis=EventListenerTouchOneByOne::create();
lis->onTouchBegan=[=](Touch* ptouch, Event* pevent)
{
return true;
};
lis->onTouchEnded=[=](Touch* ptouch, Event* pevent)
{
};
lis->onTouchMoved=[=](Touch* ptouch, Event* pevent)
{
Vec2 p=ptouch->getLocation();
auto p1=this->convertToNodeSpace(p);
menu->setPosition(p1);
};
dis->addEventListenerWithSceneGraphPriority(lis, this);
this->Remote();
return true;
}