Now I'm following article http://www.cocos2d-x.org/wiki/Effects. Examples of the link make errors. Tested cocos2d-x version is cocos2d-x 3.2beta0.
My code:
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);
result logs:
Assert failed: GridActions can only used on NodeGrid
Assertion failed!
File: CCActionGrid.cpp
Line: 84
What did I mistake? even I remove liquid action line, wave3d and lens3d also show me same error.
The assertion is clear. You must use NodeGrid if you want use GridActions like Lens3D or Waves3D. If you want use this action, create NodeGride, add your sprite to them, and run action on 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With