0

I was writing a simple program using Tiled Map Editor Cocos2d and Xcode and last time I tried it it worked but now I got the new iOS 6 simulator and it doesn't. The error is just "Sigbrt" it means the signal to abort. I don't know what's wrong with my program. Here's the Hellowrold.h

//
//  HelloWorldLayer.h
//  game
//
//  Created by Alex Reichenbach on 9/29/12.
//  Copyright __MyCompanyName__ 2012. All rights reserved.
//


// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"

// HelloWorldLayer
@interface HelloWorldLayer : CCLayer
{
    CCTMXTiledMap *theMap;
    CCTMXLayer *bounds;
    CCTMXLayer *bgLayer;

}
@property (nonatomic,retain) CCTMXTiledMap *theMap;
@property (nonatomic,retain) CCTMXLayer *bounds;
@property (nonatomic,retain) CCTMXLayer *bgLayer;


// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;

@end

Here's the HellowWorldLayer.m

//
//  HelloWorldLayer.m
//  game
//
//  Created by Alex Reichenbach on 9/29/12.
//  Copyright __MyCompanyName__ 2012. All rights reserved.
//


// Import the interfaces
#import "HelloWorldLayer.h"

// HelloWorldLayer implementation
@implementation HelloWorldLayer
@synthesize theMap;
@synthesize bgLayer;
@synthesize bounds;

+(CCScene *) scene
{
    // 'scene' is an autorelease object.
    CCScene *scene = [CCScene node];

    // 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];

// add layer as a child to scene
[scene addChild: layer];

// return the scene
return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if( (self=[super init])) {


        self.theMap = [CCTMXTiledMap tiledMapWithTMXFile:@"game.tmx"];
        self.bgLayer = [theMap layerNamed:@"bg"];

        self.bounds = [_theMap layerNamed:@"by"];

        [self addChild:theMap z:-1];


}
return self;
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
    self.theMap = nil;
    self.bgLayer = nil;
    self.bounds = nil;
[super dealloc];
}
@end

and here's the Tiled program

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="32" height="54" tilewidth="10" tileheight="10">
 <tileset firstgid="1" name="Solid_blue" tilewidth="10" tileheight="10">
  <image source="Solid_blue.PNG" width="200" height="200"/>
 </tileset>
 <tileset firstgid="401" name="Light_green" tilewidth="10" tileheight="10">
  <image source="Light_green.png" width="300" height="300"/>
 </tileset>
 <layer name="bg" width="32" height="54">
  <data encoding="base64" compression="zlib">
   eJzt1bENACAMA7DwW/8XJ3EBrAXkwXukRmklKQC4yBz9GXBLAGDPjwd+YMt4nQ7D2QL3vs3R
  </data>
 </layer>
</map>
4

1 に答える 1

0
self.bounds = [_theMap layerNamed:@"by"];

投稿されたファイルには「by」という名前のレイヤーはありません。その行でそのエラーを受け取っていますか?

于 2013-07-22T23:11:03.090 に答える