【问题标题】:Cocos2d-x 4.0 Lens3D and Waves3D AnimationsCocos2d-x 4.0 Lens3D 和 Waves3D 动画
【发布时间】:2020-07-12 09:01:46
【问题描述】:

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

    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】:

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

    正确的编码方式是使用 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));
    

    【讨论】:

      猜你喜欢
      • 2015-02-04
      • 1970-01-01
      • 1970-01-01
      • 2013-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多