Camera movement on layer that is a child of scroll view

I have a main layer and that main layer contains a single child which is a scrollview, the scroll view contains a single layer called “_layer”, “_layer” have 10 images added to it. I want to move the camera on _layer. I want to create a similar movement that is available in cpp test NewRendererTest BugAutoCulling::BugAutoCulling() but in vertical direction. But I am not able to create it. Also see the attached file for full code and resources. I really need to make this work and any help of any sort will be much appreciated. Classes.zip (85.7 KB)

this is my HelloWorldScene.cpp file.

#include “HelloWorldScene.h”
#include “SimpleAudioEngine.h”

USING_NS_CC;

Scene* HelloWorld::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();

// 'layer' is an autorelease object
auto layer = HelloWorld::create();

Size visibleSize = Director::getInstance()->getWinSize();
float scaleFactorX  = visibleSize.width / 1024;
float scaleFactor  = (scaleFactorX);
layer->setScale(scaleFactor);
layer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);

// add layer as a child to scene




scene->addChild(layer);

// return the scene
return scene;

}

// on “init” you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
totalLength=0;

auto visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
float scaleFactorX  = visibleSize.width / 1024;
float scaleFactor  = (scaleFactorX);

_layer=Node::create();
_layer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
_layer->setPosition(Vec2(0.0,0.0));

this->addImagesToLayer();

 
scroll = ui::ScrollView::create();
scroll->setDirection(cocos2d::ui::ScrollView::Direction::VERTICAL);
scroll->setInertiaScrollEnabled(true);
scroll->setSize(Size(this->getContentSize().width/scaleFactor, this->getContentSize().height/scaleFactor));
scroll->setContentSize(Size(this->getContentSize().width/scaleFactor, this->getContentSize().height/scaleFactor));
 _layer->setContentSize(Size(this->getContentSize().width/scaleFactor, totalLength));
scroll->setInnerContainerSize(Size(this->getContentSize().width/scaleFactor, totalLength));
scroll->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
scroll->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
scroll->setBackGroundColor(Color3B(0,0,255));
scroll->setScrollBarEnabled(false);
scroll->addChild(_layer);
scroll->setPosition(origin);
scroll->setTouchEnabled(true);


scroll->scrollToBottom(0, false);

// this->addChild(scroll);

_mainLayer= Layer::create();
_mainLayer->setPosition(Vec2(0,0));
_mainLayer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->addChild(_mainLayer);

_mainLayer->addChild(scroll);



auto camera= Camera::createPerspective(50, (GLfloat)visibleSize.width/visibleSize.height , 1, 1000);
camera->setCameraFlag(CameraFlag::USER1);
camera->setPosition3D(Vec3(0,0,500));
camera->lookAt(Vec3(0,0,0), Vec3(0,1,0));
//visibleSize.width*.5/scaleFactor
_layer->addChild(camera);



_mainLayer->setCameraMask(1, true);





log("_layer width:%f, height:%f", _layer->getContentSize().width, _layer->getContentSize().height);


this->scheduleOnce([=](float){
   
    log("camera to move in 2 sec");
    
    auto moveBy= MoveBy::create(3, Vec2(0,totalLength-1000));
    
    
    auto callback= CallFunc:: create([=]{
    
        log("camera runing finished");
     
    });
    
    
    camera->runAction(Sequence::create(DelayTime::create(2),moveBy, moveBy->reverse(), callback ,NULL));
    
    
    
}, 2.0f, "lambda-autoculling- from cpp test");




return true;

}

void HelloWorld:: addImagesToLayer()
{

Vec2 origin = Director::getInstance()->getVisibleOrigin();


auto sprite1 = Sprite::create("image1.jpg");
totalLength=totalLength+sprite1->getContentSize().height;
auto sprite2= Sprite::create("image1.jpg");
totalLength=totalLength+sprite2->getContentSize().height;
auto sprite3= Sprite::create("image1.jpg");
totalLength=totalLength+sprite3->getContentSize().height;
auto sprite4= Sprite::create("image1.jpg");
totalLength=totalLength+sprite4->getContentSize().height;
auto sprite5= Sprite::create("image1.jpg");
totalLength=totalLength+sprite5->getContentSize().height;
auto sprite6= Sprite::create("image1.jpg");
totalLength=totalLength+sprite6->getContentSize().height;
auto sprite7= Sprite::create("image1.jpg");
totalLength=totalLength+sprite7->getContentSize().height;
auto sprite8= Sprite::create("image1.jpg");
totalLength=totalLength+sprite8->getContentSize().height;
auto sprite9= Sprite::create("image1.jpg");
totalLength=totalLength+sprite9->getContentSize().height;
auto sprite10= Sprite::create("image1.jpg");
totalLength=totalLength+sprite10->getContentSize().height;


sprite1->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite2->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite3->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite4->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite5->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite6->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite7->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite8->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite9->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
sprite10->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);

sprite1->setPosition(Vec2::ZERO);
sprite2->setPosition(Vec2(0,sprite1->getContentSize().height));
sprite3->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height));
sprite4->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height));
sprite5->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height));
sprite6->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height +sprite5->getContentSize().height));
sprite7->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height +sprite5->getContentSize().height +sprite6->getContentSize().height));
sprite8->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height +sprite5->getContentSize().height +sprite6->getContentSize().height +sprite7->getContentSize().height));
sprite9->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height +sprite5->getContentSize().height +sprite6->getContentSize().height +sprite7->getContentSize().height +sprite8->getContentSize().height));
sprite10->setPosition(Vec2(0,sprite2->getContentSize().height+ sprite1->getContentSize().height+sprite3->getContentSize().height+sprite4->getContentSize().height +sprite5->getContentSize().height +sprite6->getContentSize().height +sprite7->getContentSize().height +sprite8->getContentSize().height +sprite9->getContentSize().height));


_layer->addChild(sprite1,0,1);
_layer->addChild(sprite2);
_layer->addChild(sprite3);
_layer->addChild(sprite4);
_layer->addChild(sprite5);
_layer->addChild(sprite6,2);
_layer->addChild(sprite7);
_layer->addChild(sprite8);
_layer->addChild(sprite9);
_layer->addChild(sprite10);



ParticleSystemQuad* _snowParticle = ParticleSystemQuad::create("snowParticles2.plist");

_snowParticle->setPosition(Vec2(0, sprite6->getContentSize().height*.5));
_snowParticle->setAnchorPoint(Vec2:: ANCHOR_MIDDLE);
_snowParticle->setPositionType(cocos2d::ParticleSystem::PositionType::RELATIVE);

sprite6->addChild(_snowParticle,100);

}