cocos2dx 3.x 3d特效失败

转自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);




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值