tiled地图速度配表
This commit is contained in:
parent
2dafab9662
commit
d03f5c6957
@ -36,13 +36,15 @@ bool TiledMap::LoadTmxFile(const std::string& filename)
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::XObject> tileset_node = xobj.At("child_node.tileset")->At(0);
|
||||
tile_count = tileset_node->At("attrs.tilecount")->AsXValue();
|
||||
tile_width = tileset_node->At("attrs.tilewidth")->AsXValue();
|
||||
tile_height = tileset_node->At("attrs.tileheight")->AsXValue();
|
||||
#if 0
|
||||
tile_count = tileset_node->At("attrs.tilecount")->AsXValue();
|
||||
tile_columns = tileset_node->At("attrs.columns")->AsXValue();
|
||||
tile_rows = tile_count/tile_columns + 1;
|
||||
tile_columns += 1;
|
||||
tile_count = tile_rows * tile_columns;
|
||||
#endif
|
||||
for (int i = 0; i < xobj.At("child_node.layer")->Size(); ++i) {
|
||||
std::shared_ptr<a8::XObject> layer_node = xobj.At("child_node.layer")->At(i);
|
||||
|
||||
@ -63,6 +65,11 @@ bool TiledMap::LoadTmxFile(const std::string& filename)
|
||||
}
|
||||
|
||||
std::string layer_name = layer_node->At("attrs.name")->AsXValue();
|
||||
if (layer_name.compare("ground") == 0) {
|
||||
tile_columns = layer_node->At("attrs.width")->AsXValue();
|
||||
tile_rows = layer_node->At("attrs.height")->AsXValue();
|
||||
tile_count = tile_rows * tile_columns;
|
||||
}
|
||||
auto itr = layer_hash.find(layer_name);
|
||||
if (itr != layer_hash.end()) {
|
||||
itr->second.push_back(layer);
|
||||
@ -142,8 +149,8 @@ void TiledMap::Init()
|
||||
for (auto& layer : pair.second) {
|
||||
|
||||
std::string name = layer.GetProperty("name").GetString();
|
||||
bool has_speed = layer.HasProperty("speed");
|
||||
int speed = layer.GetProperty("speed");
|
||||
bool has_speed = layer.HasProperty("area_id");
|
||||
int speed = layer.GetProperty("area_id");
|
||||
|
||||
bool has_trigger = layer.HasProperty("isTrigger");
|
||||
bool istrigger = layer.GetProperty("isTrigger");;
|
||||
@ -439,3 +446,15 @@ std::vector<GridCell*> TiledMap::SortGridList(std::vector<GridCell*>* grid_list,
|
||||
}
|
||||
return grid_sort_list;
|
||||
}
|
||||
|
||||
void TiledMap::SetGridCellSpeedByAreaId(std::map<int,int>& area_speed_hash)
|
||||
{
|
||||
for (auto& pair : stage_path_hash) {
|
||||
for (auto& grid_cell : pair.second) {
|
||||
auto itr = area_speed_hash.find(grid_cell->speed);
|
||||
if (itr != area_speed_hash.end()) {
|
||||
grid_cell->speed = itr->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,9 @@ class TiledMap
|
||||
std::vector<GridCell*> SortGridList(std::vector<GridCell*>* grid_list, StagePoint* sp);
|
||||
bool CalcCurrPos(std::vector<int>& path_points, int old_pos_x, int old_pos_y, int time_ms, int& curr_pos_x, int& curr_pos_y);
|
||||
|
||||
//速度设置
|
||||
void SetGridCellSpeedByAreaId(std::map<int,int>& area_speed_hash);//key:area_id value:speed
|
||||
|
||||
private:
|
||||
std::map<std::string, std::list<TiledLayer>> layer_hash;
|
||||
std::map<std::string, std::list<TiledObject>> object_group_hash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user