开发者

How to use isometric orientation, cocos2d, iOS, CCTMXTiledMap

开发者 https://www.devze.com 2023-04-13 01:32 出处:网络
I\'m trying to grasp the basics of tile-based games (cocos2D, iOS development). I use \"Tiled\" - application, which makes .tmx files, which are used as tile maps. I succeeded to load orthogonal orien

I'm trying to grasp the basics of tile-based games (cocos2D, iOS development). I use "Tiled" - application, which makes .tmx files, which are used as tile maps. I succeeded to load orthogonal orientation, but I have some problems with isometric orientation: when I load .tmx file, nothing is displayed:

-(id) init
{
if ((self = [super init]))
{
    CCTMXTiledMa开发者_如何学编程p* tileMap = [CCTMXTiledMap        tiledMapWithTMXFile:@"isometric.tmx"];
    [self addChild:tileMap z:1];
}
return self;
}

As a result, I get black screen despite the fact I added background (simple green grass). My question is what am I doind wrongly and why it doesn't display background?


The visible part of an isometric tilemap is a rhombus. The default position of the tilemap is at 0,0, the lower left corner. If your iso tilemap is large enough it's possible that you don't see anything because you're looking at the part of the rhombus' bounding rectangle that doesn't contain any tiles. You need to move the tilemap into view.

Try this for example:

tileMap.position = CGPointMake(-500, -500);

This moves the position of the tilemap 500 pixels to the left and 500 down. It has the same effect as moving the viewport (iPhone screen) over the tilemap towards the right and up. Depending on the size of your tilemap tweak the position until you can see the iso map.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号