cocos2d-android collision map

How collision map? I have call:

// Get TMX Map and associated layers/groups
_map = CCTMXTiledMap.tiledMap("mapdemo.tmx");
_background = _map.layerNamed("Background");
_objects = _map.objectGroupNamed("Objects");


people can help me. check character when collision _object.

• You'll need to be more specific so that someone can help you. – Vaughan Hilts May 12 '15 at 4:43

There is a tutorial HERE that will help you using Tiled Map to create collisions as you are using this technology. Basically, if you are using Tiled Map you will mostly do Pathfinding, when you calculate the closest path to move to X,Y position, you need to check if this path contains some "collider" tiles, using a method like:

-(BOOL) isCollisioning:(CGPoint) position{
CGPoint tileCoord = [self tileCoordForPosition:position];
int tileGid = [_meta tileGIDAt:tileCoord];
if (tileGid) {
NSDictionary *properties = [_tileMap propertiesForGID:tileGid];
if (properties) {
NSString *collision = properties[@"Collidable"];
if (collision && [collision isEqualToString:@"True"]) {
return true;
}
}
}
return false;
}


So the tile is not really a physical body, but you will not be able to go inside it. Of course, it means you have prepared your Tilemap accordingly (link explains how to with a step by step).

If you wanted to make each of the squares collidable, which I don't recommend for performance and complexity issues, you will have to use an external library (for example Box2D) and create a phyisic body for each collidable tile in your tilemap (of course you should try to make bigger physic bodies if you have them together, to improve performance).

• I am not a Java expert, but i hope this helps: [object method:parameter] in Objective C is the same as object.method(parameter) in Java. NSDictionary would be a Map<object, object> (that are the properties that you should have in your tilemap, created same way the tutorial in the link shows you). Any question just ask! – aramusss May 14 '15 at 8:21