转自http://www.cocoachina.com/bbs/read.php?tid=225481
各位大神,有没比较好点的运行3d特效的例子?我创建一个新的工程,然后用Sprite来添加一个图片,然后使用cocos2dx 3d特效后运行失败,不知道怎么回事。
求大神帮忙给个例子
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(sprite, 0);
//3D晃动的特效
CCActionInterval* shaky3D = CCShaky3D::create(5, CCSize(10, 10), 15, false);
sprite->runAction(shaky3D);
失败,报异常!
错误列表
Assertion failed!
Program: ...ogram\ERMJGame\proj.win32\Debug.win32\ERMJGame.exe
File: CCActionGrid.cpp
Line: 84
Expression: _gridNodeTarget
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)
断言有提示啊: GridActions can only used on NodeGrid
不能直接让sprite执行GridActions。你需要用一个NodeGrid来承载sprite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// add "HelloWorld" splash screen"
auto
sprite = Sprite::create(
"HelloWorld.png"
);
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
//this->addChild(sprite, 0);
auto
nodegrid = NodeGrid::create();
nodegrid->addChild(sprite);
this
->addChild(nodegrid);
//run Shaky3D action
auto
shaky3D = Shaky3D::create(5, CCSize(10, 10), 15,
false
);
nodegrid->runAction(shaky3D);
|