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);
}
