Cocos2d-x 4.0 Lens3D和Waves3D动画。

问题描述 投票:1回答:1

我用下面的代码为背景图制作了类似水的动画。

    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秒...重复。如何避免动画中途停止?

c++ ios iphone xcode cocos2d-x
1个回答
1
投票

它并没有停止,而是在应用波浪效果,然后是透镜效果。当应用透镜效果时,波浪的动画就停止了。

正确的编码方式是使用一个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));
© www.soinside.com 2019 - 2024. All rights reserved.