Capture every CGPoint in a CCTMX tile map? - XCode

  • Thread starter Thread starter AmiNeo
  • Start date Start date
  • Replies Replies 1
  • Views Views 1927

AmiNeo

CodeMonkey
AmiBayer
Joined
Jul 28, 2010
Posts
7,452
Country
UK
Region
Kendal, Cumbria
Hi Guys, long time no speak! :D

Having a little trouble with implementing pathfinding in my dissertation program. I'm basically at the point where I need to check if a tile is collidable or not within the algorithm and the way I have currently implemented the tile collision isn't compatible with pathfinding, as its currently click per tile move in said direction.

Does anyone have any ideas how I can reference every CGPoint from the tile map and stick them in an array? The tile map as per title is currently imported as a CCTMX tilemap (.tmx file) and was created in TILED for Mac OS.

:thumbsup:
 
Last edited:
Ok heres some code to help out...

Code:
-(BOOL)isWall:(CGPoint)point{

    // 1 is a wall
	if ([[_tileMap objectAtIndex:point.x]CGPointValue objectAtIndex:point.y] == [NSNumber numberWithInt:1]) {
		NSLog(@"1 point: %f,%f",point.x,point.y);
		return YES;
    }
    else {
		NSLog(@"0 point: %f,%f",point.x,point.y);
		return NO;
	}
}

The issue is that _tileMap isn't valid according to XCode. It is the same name used to reference the tilemap everywhere else in the code but I think the AStar code (open source) I have borrowed is intended for a different map style and needs to see the grid as some form of array. Probably, its designed for the old 'array of ints' mapping style would be my guess.

This code is based on Gabriel Hora's implementation here: http://gabrielhora.tumblr.com/post/5412413107/plug-and-play-a-path-finding-algorithm-in-objective-c


If anyone can help me past this hurdle, I'd really appreciate it. This isn't technically part of the marks, its just something I'm trying to get in to make the game more fluid, or the player will end up with a very sore finger.

Thanks again in advance. :thumbsup:
 
Last edited:
Back
Top Bottom