Open TsukiruP opened 1 year ago
I have no context for what GMS files are supposed to have. Are you sure this isn't a general Tiled issue?
Yeah just referencing GMS1 wasn't the greatest idea. But I don't think it's a general Tiled issue as a regular problem with exports, but may be general in how Tiled normally loads graphics from images. I should've checked other formats to see how exporting differs between Neo Green Hill Zone Act 1 and a new untitled map. The untitled map I'm using is using the imgexport as a tileset image and some random image for an image layer to compare with NGH's background. But
I exported go both JSON and JavaScript map files and opened their contents in Notepad++. They're both really similar so what I'll say goes for both. For the untitled map, the tileset is referenced with source:"file.tmx" but source doesn't appear in the NGH files at all. Strange but doesn't tell us a lot. I think what's more telling is the case of the background layer. The source image of an image layer is referenced at image:"file_name.jpg", but NGH only has image:"". Since it's not actually using an image or tileset file for the graphics, which Tiled (I assume) assumes is the case all the time. I also exported to GMS2 but NGH returned a 0 bytle file and crashed. For some reason.
GMS1 also assumes an image is being used so it's room data for tiles tries to name the image and the offset of specific tiles. Due to the Advance levels not actually using an image, then Studio 1 doesn't have anything to work with and produces no offsets to load specific tiles. I think the image/background layer exemplifies this better though.
Looks like this is a known issue in Tiled. Technically I could work around it by saving the chunks as images somewhere before setting up the Tileset, but that might be a little unwieldy.
Oops, I wasn't looking hard enough then. I'd think it would allow for more use of the Tiled sets but it certainly doesn't sound like an elegant solution.
FYI this issue is being worked on in Tiled (see PR https://github.com/mapeditor/tiled/pull/3841), so hopefully in an upcoming version of Tiled (maybe 1.11?), you'll be able to save maps with embedded images.
This doesn't mean the GameMaker Studio export will support embedded images, though - that depends on whether the format supports embedded images at all, and even if it does, the exporter would probably need to be updated.
Appreciate the heads up. I'll wait on that then and take it up with Tiled should anything come up when that happens.
I've merged the referenced PR, but I don't think it will help with this issue. If you want an export to GameMaker to refer to an external image file, then somewhere that image file will need to be saved. It can be done by the loader, but if that is not desired, a custom action can be scripted that detects embedded images, saves them separately and sets up the appropriate references.
I don't have a preference as I don't have much experience with Tiled. So if you could point me in the right direction for either, I would be grateful.
@TsukiruP Hmm, ok I checked and it seems the current scripting API is not able to do this, because there is no function providing access to the embedded image. There is only Tile.imageFileName
, but no Tile.image
. I can have a look at adding this.
In any case, if you could get at the tile's image, and since this loader is setting the image of each tile individually, as done here:
Then, you would eventually be able to do something like:
let imageFileName = targetDirectory + "/tile" + tile.id + ".png";
tile.image.save(imageFileName);
tile.imageFileName = imageFileName;
And after doing that for each tile in the tileset, you could save the tileset itself and it should be an image collection tileset, which should be able to be exported to Game Maker Studio 1. You'd still need to copy the tile images to your GameMaker project, such that they can be referred to by their base name, see:
Alright, Tile.image
, as used above, should be available once https://github.com/mapeditor/tiled/pull/3882 is merged.
@bjorn Managed to pull it off like here:
Is saving them as an image collection the only option? I would've preferred making it all as one image especially as all of the tiles I aim to use are of the same size.
Edit: Further thought realizes there's no (currently) convenient way of doing this, at least within Tiled.
@TsukiruP Maybe the importer could be changed such that it doesn't create individual images for each tile, but rather extracts the entire tileset as one image. I'm not sure what the data it is reading looks like.
But indeed, there could also be a feature in Tiled that allows saving / exporting a tileset to an image. However, there are existing tools out there that can do this. Tools like TexturePacker or Atlased can probably help with aligning them on a single image, as can the command-line tool ImageMagick montage
.
@bjorn compiling the tiles isn't much of a problem, as MainMemory's tool organizes these tiles already. I want to export the layout of the tiles but just referencing a compiled image (as these all share the same size). And it looks like neither of those tools modify Tiled's files for that.
"Swap Tiles" only applies to the same tileset and while I could add the compiled image and cut it up, that's a bit tedious for all 100+ tiles and no automatic cutting that I'm aware of.
Certainly doesn't feel like I'm supposed to do this lol.
Edit: Swapped one tile and then exported to GMS, where the offset (changes in X and Y to cut) was not exported. So that's not the solution I thought it was either.
I want to use the Sonic Advance 1 level maps for a project in Game Maker Studio 1. Tiled does support exporting to GMS1 inherently, but exporting the sa1-tiled maps produces strange results such as xo and yo (offset for coordinates in the tileset/background) being set to 0 and no tile name.
In an untitled map I created using "Neo Green Hill Zone Act 1 FG High" from imgexport/Chunks as a tileset, and rooms made in Game Maker Studio, appear like this.
I figure this is due to how these projects are made, not loading a tileset from an image and using data from the Advance files itself. At the risk of talking out of my ass, I was wondering if there was anyway of creating a Tiled map of the terrain using the Chunks from imgexport. Though that would lead to awkwardness needing those chunks and asking for them, it would expand the use of the Tiled map files. It would be nice including the ring, enemy, and object placement but I'd personally just settle with having the terrain done.
Edit: Changed the title, because this likely impacts all Tiled exports rather than just my case with Game Maker Studio.