c++ - Cocos2d-x 4.0 Lens3D 和 Waves3D 动画
问题描述
我使用下面的代码为背景图像制作像水一样的动画
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));
推荐阅读
- tensorflow - 为什么手动构建 timestep-unfold LSTM 与使用 static_rnn 有不同的输出?
- javascript - 无法在 three.js 中使用 FBXLoader
- flutter - 如何使用用户的特定 ID 传递结果?
- node.js - req.file 在控制台中显示未定义
- java - 执行其他行后正在运行方法
- python - 从 sophos UTM 9 获取用户和用户详细信息的 Python API 代码
- reactjs - 在 React 中等待 useState
- java - 如何在不使用位置的情况下不同的打开活动
- python - ActionChains 中的 perform() 和 reset_actions() 不起作用 selenium python
- reactjs - How to check if my Google Drive embed videos using iframe ends?