除錯時,報錯 問題如下:
0x003172CF 處的第一機會例外(在 MonkeyKing.exe 中): 0xC0000005: 讀取位置 0xCCCCCCCC 時發生訪問沖突。
0x003172CF 處有未經處理的例外(在 MonkeyKing.exe 中): 0xC0000005: 讀取位置 0xCCCCCCCC 時發生訪問沖突。
代碼如下:
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
auto player = Sprite::create("error.png");
player->setPosition(visibleSize.width/2,visibleSize.height/2);
addChild(player);
//加載快取
SpriteFrameCache * frameCache = SpriteFrameCache::getInstance();
frameCache -> addSpriteFramesWithFile("123.plist","123.png");
//運用容器將記憶體中的影片遍歷出來。
Vector <SpriteFrame*> animation;
for(int i=1;i<9;i++)
{
char name[256]={ 0 };
sprintf(name,"chuShou%d.png",i);
SpriteFrame* a = frameCache->spriteFrameByName(name);
animation.pushBack(a);
}
//用容器中便利的內容創建物件
Animation * b = CCAnimation::createWithSpriteFrames(animation);
//0.1秒一幀
b -> setDelayPerUnit(0.1f);
b->setRestoreOriginalFrame(true);
//創建影片動作
Animate* act = CCAnimate::create(b);
//創建函式動作
auto callFunc = CallFunc::create([&](){player->removeFromParent();
});
auto sequence = Sequence::create(act, callFunc, NULL);
player->runAction(sequence); // 運行精靈物件
return true;
}
也是剛開始弄 找不到問題,請大神幫忙。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/64368.html
標籤:Cocos2d-x
下一篇:拓撲排序就這么回事
