Xcode +中的断言失败;[CCSprite SpriteWithPriteFrameName:]?
由于某种原因,+[CCSprite SpriteWithPriteFrameName::中出现断言失败 我基本上是在尝试“更新浆果”,或者换句话说,创建更多的雪碧“浆果”添加到屏幕上。他们是我游戏中的“敌人” 这是我的代码:Xcode +中的断言失败;[CCSprite SpriteWithPriteFrameName:]?,xcode,cocos2d-iphone,sprite,ccsprite,cgsize,Xcode,Cocos2d Iphone,Sprite,Ccsprite,Cgsize,由于某种原因,+[CCSprite SpriteWithPriteFrameName::中出现断言失败 我基本上是在尝试“更新浆果”,或者换句话说,创建更多的雪碧“浆果”添加到屏幕上。他们是我游戏中的“敌人” 这是我的代码: - (id) init { if((self = [super init])) { CCLOG(@"%@ init", NSStringFromClass([self class])); self.touchEnabled
- (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]];
}
}
编辑:完整断言日志:
2013-03-3119:39:09.225贝瑞·芒彻iOS[19550:c07]-[CCFileUtils
fullPathForFilename:resolutionType::cocos2d:警告:文件未
发现:Sprites.plist 2013-03-31 19:39:09.225
Muncher iOS[19550:c07]cocos2d:CCSpriteFrameCache:正在尝试使用文件
“雪碧.png”作为纹理2013-03-31 19:39:09.425
Muncher iOS[19550:c07]cocos2d:CCSpriteFrameCache:Frame'ship.png'
找不到2013-03-3119:39:09.426 Berry Muncher iOS[19550:c07]***
+[CCSprite SpriteWithPriteFrameName:]中的断言失败,
/Users/Suraya/Desktop/Kobold2D/Kobold2D-2.1.0/Kobold2D/libs/cocos2d iphone/cocos2d/CCSprite.m:105
编辑:我的plist的截图
我从Ray Wanderlich教程中了解到这一点。因为他有不同于您可能使用的艺术品,所以您应该创建自己的
CCSpriteBatchNode
和附带的plist
文件,这样他的项目名称就不会与您的项目名称混淆。我从Ray Wanderlich教程中了解到这一点。因为他有不同于您可能使用的艺术品,您应该创建自己的CCSpriteBatchNode
和附带的plist
文件,这样他的项目的项目名称就不会与您的项目名称混淆。您可以发布完整的断言日志吗?通常会有一条消息解释失败的原因。是的,肯定是我编辑的。谢谢您的spritesheet上有一个名为“ship.png”的框架吗?其他帧加载时没有问题?这是上面唯一的帧。我不熟悉雪碧床单。在“.plist”中,我刚刚添加了一个名为“ship.png”的字典。您是如何创建spritesheet的?通常你会使用像TexturePacker这样的工具。你能发布完整的断言日志吗?通常会有一条消息解释失败的原因。是的,肯定是我编辑的。谢谢您的spritesheet上有一个名为“ship.png”的框架吗?其他帧加载时没有问题?这是上面唯一的帧。我不熟悉雪碧床单。在“.plist”中,我刚刚添加了一个名为“ship.png”的字典。您是如何创建spritesheet的?通常你会使用像TexturePacker这样的工具。我创建了我的批处理节点:_batchNode=[CCSpriteBatchNode batchNodeWithFile:@“berries hd.pvr.ccz”;[self addChild:_batchnodez:-1];[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@“berries hd.plist”];它找不到我的plist或.ccz,但我在Texture Packer中创建了它们。你认为我在纹理打包机里做错了什么吗?你在纹理打包机里到底在做什么?不过,我对这个软件不太熟悉。看起来你没有做错什么。当我学习Ray Wanderlich教程时,我喜欢创建自己的项目,以避免我的文件和代码与他的混淆。我创建了批处理节点:_batchNode=[CCSpriteBatchNode batchNodeWithFile:@“berries hd.pvr.ccz”];[self addChild:_batchnodez:-1];[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@“berries hd.plist”];它找不到我的plist或.ccz,但我在Texture Packer中创建了它们。你认为我在纹理打包机里做错了什么吗?你在纹理打包机里到底在做什么?不过,我对这个软件不太熟悉。看起来你没有做错什么。当我学习Ray Wanderlich教程时,我喜欢创建自己的项目,这样我的文件和代码就不会与他的混淆。