0

我正在使用 Tiled Map Editor Cocos2d 和 Xcode 编写一个简单的程序,上次我尝试它工作但现在我得到了新的 iOS 6 模拟器,但它没有。错误只是“Sigbrt”,它意味着要中止的信号。我不知道我的程序有什么问题。这是 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

这是 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

这是平铺程序

<?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 回答