JSTileMap tileGidAtCoord not responding with all GIDs?

150 Views Asked by At

I am trying to find other child nodes within the same GID, essentially find my neighbor nodes. However, in my 25x25 map I only retrieve 4 GIDs for some reason, 6, 7, 19, and 20. My understanding is that there should be 625 GIDs, one for each tile, - but maybe I do not understand Tile Maps that well. When I load the view I see the map and the players fine, randomly positioned around as I would want.

I am using a 25x25 tile map, 16x16 pixels each tile, and I randomly add player nodes to a JSTileMap between 0 and 400 for x and y. My map has one layer.

agent.player.position = CGPointMake(agent.xPos.floatValue, agent.yPos.floatValue);
agent.player.zPosition = 15;
[self.map addChild:agent.player];

Then I convert the position to a JSTileMap point, because I understand it inverts the y axis.

TMXLayer *layer = self.ground;
CGPoint playerCoord = [layer coordForPoint:agent.player.position];

Then I want to retrieve the GID for this player and store it in a dictionary so I can later find out who all the neighbors are.

TMXLayerInfo *layerInfo = layer.layerInfo;
NSInteger currentTileGID = [layerInfo tileGidAtCoord:playerCoord];

Interestingly currentTileGID only has values of 6, 7, 19, or 20, despite what I would think would be random GIDs between 1 and 625. What I am not understanding about this behavior? The input playerCoord values seem correct as random from 0 to 400 for both x and y.

Thank you, lta

0

There are 0 best solutions below