onTouchMoved not working!

onTouchMoved not working!

    auto listener = EventListenerTouchOneByOne::create();
	listener->setSwallowTouches(true);
	

	listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
	listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);
	listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);

	_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

bool HelloWorld::onTouchBegan(Touch* touch, Event* event)
{
	auto f = static_cast<Sprite*>(getChildByTag(DRAG_BODYS_TAG));
	f->setPosition(touch->getLocation());
	CCLOG("Begin");
	auto location = touch->getLocation();
	auto arr = m_World->getShapes(location);

	PhysicsBody* body = nullptr;
	for (auto& obj : arr)
	{
		if ((obj->getBody()->getTag() & DRAG_BODYS_TAG) != 0)
		{
			body = obj->getBody();
			break;
		}
	}

	if (body != nullptr)
	{
		Node* mouse = Node::create();
		mouse->setPhysicsBody(PhysicsBody::create(PHYSICS_INFINITY, PHYSICS_INFINITY));
		mouse->getPhysicsBody()->setDynamic(false);
		mouse->setPosition(location);
		this->addChild(mouse);
		PhysicsJointPin* joint = PhysicsJointPin::construct(mouse->getPhysicsBody(), body, location);
		joint->setMaxForce(5000.0f * body->getMass());
		m_World->addJoint(joint);
		_mouses.insert(std::make_pair(touch->getID(), mouse));

		return true;
	}
	
	return false;
}

void HelloWorld::onTouchMoved(Touch* touch, Event* event)
{
	CCLOG("Moved");
	auto it = _mouses.find(touch->getID());

	if (it != _mouses.end())
	{
		it->second->setPosition(touch->getLocation());
	}
}

void HelloWorld::onTouchEnded(Touch* touch, Event* event)
{
	CCLOG("Ended");
	auto it = _mouses.find(touch->getID());

	if (it != _mouses.end())
	{
		this->removeChild(it->second);
		_mouses.erase(it);
	}

}

In output window
only

Begin

You wrote

listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);

instead of

listener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);

As in you set the onTouchEnded callback to onTouchMoved, then overwrite it with the next line which set the onTouchEnded callback to onTouchEnded.

I overwrite it.But problem still. Then i use multitouches and it works fine. But why?

Was auto listener = EventListenerTouchOneByOne::create(); the only line you changed to make it work?

Yes, I checked

auto listener = EventListenerTouchOneByOne::create();
	if (listener)
		CCLOG("listener OK");

I created another project and have the same result. Maybe, it my mouse

So you changed the line I told you to change and it didn’t work?