I'm trying to find the position in pixels of a particular tile in my .tmx map. The method positionAt: of the CCTMXLayer class should do the trick, but whenever I try to use it, it returns a CGPoint with coordinates (0,0).. This is part of the code I'm using.
// CCTMXTiledMap Declaration using my class MapLayer
//which inherits from CCTMXTiledMap
MapLayer *tileMap = [MapLayer node];
CCTMXLayer *myLayer = [tileMap layerNamed: @"Middle"];
NSLog(@"%i", [myLayer positionAt: CGPointMake(x,y)].x);
NSLog(@"%i", [myLayer positionAt: CGPointMake(x,y)].y);
No matter what the values for x and y are for the CGPointMake, the values for the CGPoint (0,0) keep getting logged and I don't understand why.
EDIT:
Am I just declaring my layer with the map wrong? This is my code.
//init method for MapLayer.m class file
@implementation MapLayer
-(id) init {
if( (self=[super initWithTMXFile: @"ZombearTilemap.tmx"])) {
}
return self;
}
//in my MainScene.m class init method
MapLayer *tileMap = [MapLayer node];
[self addChild: tileMap];
CCTMXLayer *tileMapLayer = [tileMap layerNamed: @"Middle"];
// (tileMapLayer == nil) returns false
//tileMap.mapSize.width returns 0
//[[tileMapLayer tileAt:ccp(x,y)] boundingBox].size.height returns 0