【发布时间】:2011-11-05 16:25:01
【问题描述】:
我关注了很多关于如何在 cocos2d 中动画精灵的视频。但是当代码运行时,我似乎总是遇到这种情况。
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode SpriteSheetWithFile:@"animbear.png"];
它说(线程 1:程序收到信号“SIGBRT”)
我不确定我已经尝试了所有可以帮助的方法?
这是 init 方法中的代码 这是代码的一部分!
// Import the interfaces
#import "HelloWorldLayer.h"
// HelloWorldLayer implementation
@implementation HelloWorldLayer
// At the top, under @implementation
@synthesize bear = _bear;
@synthesize moveAction = _moveAction;
@synthesize walkAction = _walkAction;
-(id) init {
if((self = [super init])) {
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
@"bear.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:@"bear.jpg"];
[self addChild:spriteSheet];
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject: *****THIS IS WERE (PROGRAM RECEIVED SIGNAL:"SIGABRT***
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"bear%d.png", i]]];
}
CCAnimation *walkAnim = [CCAnimation
animationWithFrames:walkAnimFrames delay:0.1f];
CGSize winSize = [CCDirector sharedDirector].winSize;
self.bear = [CCSprite spriteWithSpriteFrameName:@"bear.jpg"];
_bear.position = ccp(winSize.width/2, winSize.height/2);
self.walkAction = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
[_bear runAction:_walkAction];
[spriteSheet addChild:_bear];
}
return self;
}
【问题讨论】:
-
当此问题崩溃时,请按 CMD + Shift + R,然后将控制台窗口的内容复制/粘贴到此问题中。
标签: objective-c xcode4 cocos2d-iphone