由於某種原因,我在+ [CCSprite spriteWithSpriteFrameName:]中收到聲明失敗。+ [CCSprite spriteWithSpriteFrameName:]中的聲明失敗
我基本上試圖「updatePinkBerries」或換句話說,創建更多的精靈'漿果'被添加到屏幕上。他們是我的比賽中的'敵人'。
這是我的代碼:
- (id) init
{
if((self = [super init]))
{
CCLOG(@"%@ init", NSStringFromClass([self class]));
self.touchEnabled = YES;
[self scheduleUpdate];
}
return self;
}
-(void)updatePinkBerries:(ccTime)dt
{
CGSize winSize = [CCDirector sharedDirector].winSize;
double curTime = CACurrentMediaTime();
if (curTime > _nextPinkBerrySpawn)
{
// Figure out the next time to spawn an asteroid
float randSecs = randomValueBetween(0.20, 1.0); _nextPinkBerrySpawn = randSecs + curTime;
// Figure out a random Y value to spawn at
float randY = randomValueBetween(0.0, winSize.height);
// Figure out a random amount of time to move from right to left
float randDuration = randomValueBetween(2.0, 10.0);
// Create a new asteroid sprite
CCSprite *pinkBerry = [CCSprite spriteWithSpriteFrameName:@"ship.png"]; [_batchNode addChild:pinkBerry];
// Set its position to be offscreen to the right
pinkBerry.position = ccp(winSize.width + pinkBerry.contentSize.width/2, randY);
// Move it offscreen to the left, and when it's done, call removeNode
[pinkBerry runAction:
[CCSequence actions:
[CCMoveBy actionWithDuration:randDuration position:ccp(-winSize.width- pinkBerry.contentSize.width, 0)],
[CCCallFuncN actionWithTarget:self selector:@selector(removeNode:)], nil]];
}
}
編輯:FULL ASSERTION LOG:
2013年3月31日19:39:09.225漿果Muncher-IOS [19550:C07] - [CCFileUtils fullPathForFilename:resolutionType:]:cocos2d的:警告:文件未找到 :Sprites.plist 2013年3月31日19:39:09.225貝瑞 Muncher-IOS [19550:C07]的cocos2d:CCSpriteFrameCache:嘗試使用文件 「精靈.png'as texture 2013-03-31 19:39:09.425 Berry Muncher-iOS [19550:c07] cocos2d:CCSpriteFrameCache:Frame'ship.png' 找不到2013-03-31 19:39:09.426 Berry Muncher-iOS [19550:c07] *** + CCSprite spriteWithSpriteFrameName:], /Users/Suraya/Desktop/Kobold2D/Kobold2D-2.1.0/ Kobold2D /libs/cocos2d-iphone/cocos2d/CCSprite.m:105
編輯:我的plist的屏幕截圖
你可以發佈完整的斷言日誌嗎?通常會有一條消息解釋失敗的原因。 –
是的,我確實編輯過它。謝謝! – Surz
你的Spritesheet上有一個名爲'ship.png'的框架嗎?其他幀加載沒有問題? –