Game Development Reference
In-Depth Information
Using
Orthogonal
Tilemaps
with
Co-
cos2d
To use TMX tilemaps with cocos2d, you first have to add the TMX file and the accom-
panying tileset image files as resources to your Xcode project. In the TileMap01 pro-
ject, I added orthogonal.tmx along with the tilesets dg_grounds32.png
and game-events.png . Loading and displaying the tilemap is very straightforward;
the following code is the interface of the TileMapLayer class:
#import "cocos2d.h"
enum
{
TileMapNode = 0,
};
@interface TileMapLayer : CCLayer
{
}
+(id) scene;
@end
And this is the TileMapLayer implementation which loads a tilemap and hides the
GameEventLayer :
#import "TileMapLayer.h"
#import "SimpleAudioEngine.h"
@implementation TileMapLayer
+(id) scene
{
CCScene *scene = [CCScene node];
TileMapLayer *layer = [TileMapLayer node];
[scene addChild: layer];
return scene;
}
Search Nedrilad ::




Custom Search