fork download
  1. #include <iostream>
  2.  
  3. namespace cocos2d {
  4.  
  5. class TMXTilesetInfo {
  6. public:
  7. std::string _sourceImage = "Test Image Name";
  8. };
  9.  
  10. class TMXLayer {
  11.  
  12. TMXTilesetInfo* _tileSet = new TMXTilesetInfo();
  13.  
  14. public:
  15. TMXTilesetInfo* getTileSet() const { return _tileSet; }
  16. };
  17.  
  18. }
  19.  
  20. void loadCollisionsDescription(std::string descriptionFileName) {
  21. std::cout << descriptionFileName;
  22. }
  23.  
  24. class PhysicsProcessorPrivate {
  25. cocos2d::TMXLayer *m_terrainLayer;
  26. public:
  27. void setTerrainLayer(cocos2d::TMXLayer *const layer);
  28. };
  29.  
  30.  
  31. void PhysicsProcessorPrivate::setTerrainLayer(cocos2d::TMXLayer *const layer) {
  32. m_terrainLayer = layer;
  33.  
  34. if (layer) {
  35. const auto tileSet = layer->getTileSet();
  36.  
  37. if (tileSet) {
  38. auto sourceImageName = tileSet->_sourceImage;
  39.  
  40. if (!sourceImageName.empty()) {
  41. auto descriptionFileName = sourceImageName + ".collisions.xml";
  42. loadCollisionsDescription(descriptionFileName);
  43. }
  44. }
  45. }
  46. }
  47.  
  48. /** Далее - cocos2d::TMXLayer::getTileSet() **/
  49. //TMXTilesetInfo* getTileSet() const { return _tileSet; }
  50.  
  51.  
  52.  
  53.  
  54. int main() {
  55. // your code goes here
  56. PhysicsProcessorPrivate pp;
  57. cocos2d::TMXLayer l;
  58.  
  59. pp.setTerrainLayer(&l);
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Test Image Name.collisions.xml