Firing bullets. MoveTo centre position of a Node object

Hi,
I am trying to fire bullets at the enemies in a tower defense game. My gun turret fires bullets (which are sprite objects) at the given target (which is a node object). I am using MoveTo action for moving the bullets fired from the gun turret to the target. What I want is the bullets to end up at the centre position of the target. Currently they are ending way up high in y-axis and off centre in x-axis. Below is the code I am using. Any help would be greatly appreciated.
Thank you.

bool ShootsEffectBullets::init( Unit * base, Unit * target, const Point & addposition )
{
Sprite::init();
Point a = base->getPosition( ) + addposition;
Point b = target->getPosition() + Point( 0, 20 );
float angle = getDirectionByVector( b-a );

auto bullet = ImageManager::sprite( "images/Tracer1.png" );
bullet->setRotation( angle );
bullet->setPosition( base->getPosition() );
bullet->setColor(Color3B::RED);
addChild(bullet);
bullet->setScale(0.5f);
auto moveTo = MoveTo::create( 0.1f, b);
auto delay = DelayTime::create( 0.05f );
auto remover = CallFunc::create( [this](){this->removeFromParent(); } );
auto action1 = Sequence::create( moveTo, delay, remover, nullptr );
bullet->runAction( action1 );

return true;

}

No one to help me with this? :disappointed:

To me it is magic numbers 0 and 20. Is your target scaled and aren’t you missing scale as well as these 20 should be somehow connected to content size of the sprite?

Ahh sorry. Actually forgot to remove that. Just added that Point(0, 20) to test out something which did not work. It doesn’t work in the way I want it to work even when I remove that addition of Point(0, 20)
The target scale will be changing as different targets are of different sizes. What I want to achieve is get the center position of the node object no matter what the size of the sprite is.

Checkout for anchor points of target nodes. Maybe you set it for example top left or something like that and it goes to that position.

Yes. The anchor point is set to Middle on target node. But thanks for reminding me about the anchor point. I did not set any anchor point on the bullet sprite. So I set up the anchor point on bullet sprite now and it is working as I wanted.
For anyone who checks this post for a solution I am pasting my code below.

bool ShootsEffectBullets::init( Unit * base, Unit * target, const Point & addposition )
{
Sprite::init();
Point a = base->getPosition( ) + addposition;
Point b = target->getPosition( );
float angle = getDirectionByVector( b-a );

auto bullet = ImageManager::sprite( "images/Tracer1.png" );
bullet->setRotation( angle );
bullet->setPosition( a );
bullet->setColor(Color3B::RED);
bullet->setAnchorPoint(Point(1, 0.5f));
addChild(bullet);
bullet->setScale(0.5f);
auto moveTo = MoveTo::create( 0.1f, b);
auto delay = DelayTime::create( 0 );
auto remover = CallFunc::create( [this](){this->removeFromParent(); } );
auto action1 = Sequence::create( moveTo, delay, remover, nullptr );
bullet->runAction( action1 );

return true;

}

I want to find the coordinates of a point inside of my gun turret sprite so that I can use if to offset the position from where the bullets are fired. Is there any software that can help with this?