MoveTo strange behavior

Here is code:

void BaseTower::attack(float delta)
{
    auto startPos = getPosition();
//    auto targetPos = currTarget->getPosition();
    auto targetPos = Vec2(100.0f, 100.0f); // for testing 
    auto bullet = cocos2d::DrawNode::create();
    bullet->drawDot(startPos, 3.0f, Color4F::BLACK);
    getParent()->addChild(bullet); // add as chid to scene object

    auto shootAct = MoveTo::create(0.5f, targetPos);
    bullet->runAction(Sequence::create(shootAct, RemoveSelf::create(true), nullptr));
}

BaseTower is a subclass of Sprite and its object is a child of a Scene object. The problem is shootAct moves bullet to 100,100 relatively to the BaseTower object origin not to the Scene object origin. So why shootAct acts like that?

Can you show a picture?

1

are you sure that getParent()->addChild(bullet); is actually the Scene?

Yes parent is subclassed Scene.

if you want to DM me your source and resources I can try to work with it.

I’m new at this forum. I cant find how to send you source.

Look on your profile page. You can create a direct message there.

I’ve sended classes and resources to you.

It seems bullet is child of Tower and Tower is child of scene.
you need to convert the position, i don’t clearly remember the exact code, will check it later.
try convertToNodeSpace or convertToWorldSpace.

This is what I thought too. Looking at the picture the bullet must have a parent other than what OP thinks.

I have cheked getParent pointer address and Scene pointer address they are the same.