Cocos2dx action error: fluid, wave3d and lens3d

Now I follow the article http://www.cocos2d-x.org/wiki/Effects . Sample links make mistakes. Tested version of cocos2d-x cocos2d-x 3.2beta0 .

My code is:

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 have I done? even I delete the line of action of the fluid , wave3d and lens3d also show me the same error.

+5
source share
1 answer

The statement is clear. You must use NodeGrid if you want to use GridActions like Lens3D or Waves3D. If you want to use this action, create a NodeGride, add a sprite to them and run the 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); 
+4
source

Source: https://habr.com/ru/post/1200650/


All Articles