【问题标题】:cocos2d sprite animation "SIGABRT"cocos2d 精灵动画“SIGABRT”
【发布时间】: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


【解决方案1】:

您是否已将 animbear.png 添加到您的项目中?

【讨论】:

  • 遗憾的是,因为 animbear.png,我知道他在说什么教程。
  • 解决办法是多出去走走 :)
  • 出去?出哪里?我不喜欢你所说的这种“出局”的声音。
【解决方案2】:

确保在使用 Zwoptex 发布 PNG 和 PLIST 文件之前保存工作表

【讨论】:

    猜你喜欢
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    • 2014-05-16
    • 2013-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多