Cocos2d-x 4.0 Lens3D 和 Waves3D 动画

Cocos2d-x 4.0 Lens3D and Waves3D Animations

我使用下面的代码为背景图像制作了像水一样的动画

    auto background = Sprite::create(TEX_MM_BG);
    background->setPosition(Vec2(SW*0.5f, SH*0.5f));

    auto nodeGrid = NodeGrid::create();
    nodeGrid->addChild(background);
    this->addChild(nodeGrid, 0);


    ActionInterval* lens = Lens3D::create(10, Size(32, 24), Vec2(100, 180), 150);
    ActionInterval* waves = Waves3D::create(10, Size(15, 10), 18, 15);

    nodeGrid->runAction(RepeatForever::create(Sequence::create(waves,lens, NULL)));

动画效果不错。但它停止 10 秒然后播放 10 秒然后再次停止 10 秒......它重复。如何避免中途停车?

它不会停止应用波浪效果,然后应用透镜效果。应用镜头效果时,波浪动画停止。

正确的编码方式是使用 Spawn:

 ActionInterval* lens = Lens3D::create(10, Size(32, 24), Vec2(100, 180), 150);
 ActionInterval* waves = Waves3D::create(10, Size(15, 10), 18, 15);
 // Spawn will run both effects at the same time.
 auto lensWaveSpawn = Spawn::createWithTwoActions(lens, waves);

 auto seq = Sequence::create(lensWaveSpawn, nullptr);
 nodeGrid->runAction(RepeatForever::create(seq));