gpt4 book ai didi

c++ - Cocos2d-x 4.0 Lens3D和Waves3D动画

转载 作者:行者123 更新时间:2023-12-01 21:58:11 25 4
gpt4 key购买 nike

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

    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));

关于c++ - Cocos2d-x 4.0 Lens3D和Waves3D动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60956882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com