0
使用它們
最近我跟着使用cocos2d的碰撞檢測的教程與平鋪創建TMX文件:http://www.raywenderlich.com/1186/collisions-and-collectables-how-to-make-a-tile-based-game-with-cocos2d-part-2分配碰撞特性對瓷磚層和在cocos2d
雖然這將是非常有用的,我想還能夠檢測整個圖層上的瓦片的碰撞特性,而不是檢測單個瓦片上的碰撞特性。
我注意到在Tiled上,你可以右鍵點擊一個圖層,並像使用單個圖塊一樣分配屬性。
裏面在我的代碼的方法我有檢查瓷磚的特性的一種方式:
CGPoint tileCoord = [self tileCoordForPosition:position];
int tileGid = [invisiblePropertiesLayer tileGIDAt:tileCoord];
if(tileGid){
NSDictionary *properties = [theMap propertiesForGID:tileGid];
if(properties){
NSString *collision = [properties valueForKey:@"collidable"];
if(collision && [collision compare:@"true"] == NSOrderedSame) {
return;
}
}
}
有沒有一種方法,如果我有任何瓷磚特定層上的碰撞,我可以改變這個檢查?謝謝!