Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2dx action error: liquid, wave3d and lens3d

Tags:

c++

cocos2d-x

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.

like image 640
BaHwan Han Avatar asked Aug 19 '14 06:08

BaHwan Han


1 Answers

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);
like image 111
Wez Sie Tato Avatar answered Nov 04 '22 05:11

Wez Sie Tato