cocos2dx动作错误:液体、波浪3D和透镜3D。

5
现在我正在阅读这篇文章: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

我错在哪里?即使我删除了液体动作线wave3dlens3d,也会显示相同的错误。

这是alpha版本的一个限制:请看这里:http://stackoverflow.com/questions/22650122/cant-use-effects-in-cocos2d-x-3-0-alpha-2 - yangguang1029
我要提一下你链接的 Effects 文档中没有包含 NodeGrid 的注释,而且很难让 Cocos 的文档得到更新。 - TankorSmash
1个回答

5
断言很清楚。如果您想使用GridActions,例如Lens3D或Waves3D,则必须使用NodeGrid。如果要使用此操作,请创建NodeGride,将您的精灵添加到其中,并在NodeGrid上运行操作。
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);

4
我是否是唯一一个觉得文档应该提到这点的人?有人应该修复那个教程,因为它明显在简单的精灵上使用了那些效果,而不是在NodeGrids上。 - Anderson Madeira

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接