现在我关注文章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);
Run Code Online (Sandbox Code Playgroud)
结果日志:
Assert failed: GridActions can only used on NodeGrid
Assertion failed!
File: CCActionGrid.cpp
Line: 84
Run Code Online (Sandbox Code Playgroud)
我弄错了什么?即使我删除液体动作线,wave3d和lens3d也显示我同样的错误.
断言是明确的。如果要使用 Lens3D 或 Waves3D 之类的 GridAction,则必须使用 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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1454 次 |
| 最近记录: |