gpt4 book ai didi

cocos2d-x - 带有 plist 的 COCOS2DX 中的 SpriteAnimation

转载 作者:行者123 更新时间:2023-12-01 06:39:20 25 4
gpt4 key购买 nike

你好,我正在使用此代码使用 cocos2dx 为 Sprite 设置动画。

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("suhas.plist");
CCLog("#########################");
CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::batchNodeWithFile("suhas.PNG");
CCLog("*********************************");
this->addChild(spriteSheet);
CCLog("*********************************");
CCArray *bearArray = new CCArray();
for(int i = 1; i <= 8; i++)
{
CCLog("*********************************");
char name[32] = {0};
sprintf(name, "bear%d.png",i);
bearArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name));
}
CCAnimation *walkAnim = CCAnimation::animationWithSpriteFrames(bearArray, 0.1f);
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite *bear = CCSprite::spriteWithSpriteFrameName("bear1.png");
bear->setPosition(ccp(size.width/2, size.height/2));
CCAction *walkAction = CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(walkAnim));
bear->runAction(walkAction);
spriteSheet->addChild(bear);
return true;

但是我的代码在崩溃。并给出错误
cocos2d: CCSpriteFrameCache: Trying to use file D:\cocos2dnew\SPRITEAnimDemo\Resources\suhas.png as texture
First-chance exception at 0x00000000 in SPRITEAnimDemo.win32.exe: 0xC0000005: Access violation.
Unhandled exception at 0x00000000 in SPRITEAnimDemo.win32.exe: 0xC0000005: Access violation.
The program '[1012] SPRITEAnimDemo.win32.exe: Native' has exited with code -1073741819 (0xc0000005).

我尝试在谷歌上解决这个问题。请帮我。

最佳答案

改变这一行

*spriteSheet = CCSpriteBatchNode::batchNodeWithFile("suhas.PNG");


*spriteSheet = CCSpriteBatchNode::batchNodeWithFile("suhas.png");

关于cocos2d-x - 带有 plist 的 COCOS2DX 中的 SpriteAnimation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12330583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com