gpt4 book ai didi

c++ - cocos2dx Action 错误: liquid, wave3d和lens3d

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:34:35 26 4
gpt4 key购买 nike

现在我正在关注文章 http://www.cocos2d-x.org/wiki/Effects .实例链接出错。测试的cocos2d-x版本为cocos2d-x 3.2beta0

我的代码:

auto bgimage = Sprite::create("top.png");
bgimage->setPosition(visibleSize / 2);

// create a Lens3D action
ActionInterval* lens = Lens3D::create(10, Size(32, 24), Vec2(100, 180), 150);

// create a Waved3D action
ActionInterval* waves = Waves3D::create(10, Size(15, 10), 18, 15);

// create a sequence an repeat it forever
bgimage->runAction(RepeatForever::create(Sequence::create(waves, lens, NULL)));

this->addChild(bgimage);

结果日志:

Assert failed: GridActions can only used on NodeGrid

Assertion failed!

File: CCActionGrid.cpp
Line: 84

我做错了什么?即使我删除了 liquid action linewave3dlens3d 也显示相同的错误。

最佳答案

断言很明确。如果你想使用像 Lens3D 或 Waves3D 这样的 GridActions,你必须使用 NodeGrid。如果你想使用这个 Action ,创建 NodeGride,将你的 Sprite 添加到它们,然后在 NodeGrid 上运行 Action 。

auto bgimage = Sprite::create("top.png");
bgimage->setPosition(visibleSize / 2);

// create a Lens3D action
ActionInterval* lens = Lens3D::create(10, Size(32, 24), Vec2(100, 180), 150);

// create a Waved3D action
ActionInterval* waves = Waves3D::create(10, Size(15, 10), 18, 15);

// create a sequence an repeat it forever
auto nodeGrid = NodeGrid::create();
nodeGrid->addChild(bgimage);
nodeGrid->runAction(RepeatForever::create(Sequence::create(waves, lens, NULL)));

this->addChild(nodeGrid);

关于c++ - cocos2dx Action 错误: liquid, wave3d和lens3d,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25376963/

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