cavestory-development
cavestory-development copied to clipboard
tiled level is not rendering
hello, thanks for the tutorial. i'm having a problem with it though. i'm not getting errors, it compiles fine, i can move the hero sprite around but, the tiled level is not rendering. please see screenshot. below is my "content" and "maps" directories. i don't think i'm missing a file ? also the map shows correctly in tiled.
MBP: cavestory-development
$ tree content/ maps/
content/
├── backgrounds
│ └── bkBlue.png
├── sprites
│ ├── MyChar.png
│ ├── NpcCemet.png
│ └── TextBox.png
└── tilesets
├── NpcSym.png
└── PrtCave.png
maps/
├── Map 1.tmx
└── Map 2.tmx
3 directories, 8 files
MBP: cavestory-development
This and #4 may be related to the fact that the map files use a path for the tileset that is relative to the tmx file, while the binary needs a path relative to where it is. This seems to work fine for however Limeoats has his eclipse project set up, but doesn't seem to work if you are running your own binary.
I'm still pretty early on in the YouTube videos, finished Part 3 of "The level class", however rather than using the path in the source attribute of the tmx directly I've added code to extract the filename and rebuilt the path used by the game to be relative to my binary.
const char* source = pTileset->FirstChildElement("image")->Attribute("source");
char* path = "content/tilesets/"; // Where my tilesets are located
std::string file = source; // Use a string object created from the c_str source
std::string filename = file.substr(file.find_last_of("/") + 1); // Find the file's name which is after the last / in the path
std::stringstream ss;
ss << path << filename; // Pass the path and the filename into the stringstream instead of source
thanks for telling !