About physicsWorld by cocos2dx

I want to drop one sprite from the place I touched. However, with this code two sprites are created from the touched location. Please tell me how to operate properly. Thanks

bool HelloWorld::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event)
{
Vec2 location = touch->getLocation();
addNewSpriteAtPosition(location);
return true;
}

void HelloWorld::addNewSpriteAtPosition(Vec2 p)
{
auto sp = Sprite::create(“aaa.png”);
sp->setPosition(p);
auto body = PhysicsBody::createCircle(sp->getContentSize().width / 2);
sp->setPhysicsBody(body);
this->addChild(sp, 1);
}

d

hi
try this :

bool HelloWorld::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event)
{
Vec2 location = touch->getLocation();
addNewSpriteAtPosition(location);
return false;
}

instead of returning true in touch Began , return false.

I tried it the first time, but it did not fix it.

I do not know well but I solved it.

Have you looked at our Programmers Guide, by chance?