I have a ParallaxNode, i add few other nodes as children, now i want to change position of one of the child node. For Ex:
auto p = ParallaxNode::create();
for (int i = 0; i < 1; i++)
{
auto rock = Sprite::create("rock.png");
rock->setAnchorPoint(Vec2::ZERO);
p->addChild(rock, 0, Vec2(0.5f, 20.5f), Vec2(450*i, ground->getContentSize().height));
}
for (int i = 0; i < 1; i++)
{
auto rock = Sprite::create("tree.png");
rock->setAnchorPoint(Vec2::ZERO);
p->addChild(rock, 0, Vec2(1.5f, 0.2f), Vec2(120*i, ground->getContentSize().height - 10));
}
this->addChild(p);
//p->runAction(MoveBy::create(30, Vec2(-1000, 0)));
auto c = p->getChildren();
auto n = c.at(1);
n->setPosition(visibleSize.width / 2, visibleSize.height / 2); <= hope a child node will be set at the center of the screen, but nothing happen
The only method to manipulate is using _parallaxArray like this tutorials:
auto po = (PointObject*)_parallaxArray->arr[i];
// If yes increase its current offset on the value of visible width
if(po->getChild() == node)
po->setOffset(po->getOffset() + Point(visibleSize.width + node->getContentSize().width,0));
But in this case, we need to create another PointObject class inherit from Ref class to work correctly.
My question is is there any other/better method ?