coco2dx在运行动画的时候出错,下附代码和说明,还请大神赐教
cocos2d吧
全部回复
仅看楼主
level 1
auto cache=SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("leftswordr_stand.plist");
Vector<SpriteFrame*> vec;
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_000.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_001.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_002.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_003.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_004.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_005.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_006.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_007.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_008.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_009.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_010.png"));
vec.pushBack(cache->getSpriteFrameByName("leftswordr_stand_011.png"));
auto ani=Animation::createWithSpriteFrames(vec,0.1f);
auto an=Animate::create(ani);
player->runAction(RepeatForever::create(an));//我认为代码在这个线程出错
VS自动跟踪错误时发现
frameToDisplay = frame->getSpriteFrame();//执行这条语句后引发异常,函数返回
static_cast<Sprite*>(_target)->setSpriteFrame(frameToDisplay);//函数返回时要执行的下一条语句
下面是报错信息:
0x00000000 处的第一机会异常(在 MyGame.exe 中): 0xC0000005: 执行位置 0x00000000 时发生访问冲突。
0x77A1BDA1 处有未经处理的异常(在 MyGame.exe 中): 0xC0000005: 执行位置 0x00000000 时发生访问冲突。
player是一个Node,当我把它改成一个Sprite后错误信息变成了:Assert failed: Invalid GLProgramStateAssertion failed!Program: F:\MyGame\proj.win32\Debug.win32\libcocos2d.dllFile: ..\renderer\CCQuadCommand.cppLine: 50Expression: shaderFor information on how your program can cause an assertionfailure, see the Visual C++ documentation on asserts
2015年08月29日 12点08分 1
1