@iQD
Hi… thanks for replying…
Ammm…
I re read my post… I think I made my 2nd point a little absurd and it was the most important point of my post…
Oh… Anyways, here is what I want to say again…
Here is what I actually did.
I made a sprite/node and added a child to it which was relatively just half the screen down towards it…
Now, I made my layer to follow this child (and not the parent sprite/node) .
I was expecting that layer would follow child node keeping it at the center, so my parent node will automatically be seen as it is 2/3 the height of the screen.
BUT something weird happened and layer followed nothing. But it was fixed at some random position, and no following…
Here is my code…
Sprite *sp= Sprite::create("1.png");
sp->setScale(0.3);
// Below statement positions my sp at 2/3 height of the screen with x coordinate in the middle of screenWidth
sp->setPosition(Vec2(...));
Sprite *sp2= Sprite::create("2.png"); // sp2 is my dummy sprite, it can be sprite with no texture also
// Below statement positions my sp2 relative to sp and hence it makes sp2 appear at the center of the screen
sp2->setPosition(Vec2(0.6*sp->getContentSize().width,-visibleSize.height/(4*0.3)));
float playfield_width = size.width * 2.0; // make the x-boundry 2 times the screen width
float playfield_height = size.height * 2.0; // make the y-boundry 2 times the screen height
// Here **this** is my layer
this->runAction(Follow::create(sp2, Rect( center.x, center.y - playfield_height/4 , 0,playfield_height/2)));
Note: My sprites have physics body so they fall vertically by themselves under gravity…
Now, layer doesnot follow anything but it is making some random point as the center of the screen and also it is not following it…
I was expecting that layer would follow my sp2(dummy sprite) so that sp2 would always be in the center of the screen, which will automatically make my parent sprite (sp) to be positioned at the 2/3 height of the screen…
Note:
If I change, in below code , from sp2 to sp2, this code works fine but it makes sp as the center which I don’t want.
this->runAction(Follow::create(sp2, Rect( center.x, center.y - playfield_height/4 , 0,playfield_height/2)));
Thanks…