Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripting interface TileMap.tileToPixel returns input #3054

Closed
mrmasterplan opened this issue May 2, 2021 · 3 comments
Closed

scripting interface TileMap.tileToPixel returns input #3054

mrmasterplan opened this issue May 2, 2021 · 3 comments
Labels
missing feature It's not just a feature, it's a feature that really should be there!

Comments

@mrmasterplan
Copy link
Contributor

mrmasterplan commented May 2, 2021

As the title says. Using the scripting function TileMap.tileToPixel(x,y) in a registered custom file writer returns the input values instead of the pixel coordinates as described in the documentation.

@bjorn
Copy link
Member

bjorn commented May 3, 2021

Ah, I'm afraid that currently this conversion function only works for opened maps, and not for maps that are being saved or maps that have been created using new TileMap(). This is because it relies on the MapRenderer instance to do the conversion and this instance is stored in the MapDocument, which is only available for open files.

But of course this function should always work, so we'll need to figure out some solution. The EditableMap class could instantiate its own MapRenderer, or the MapRenderer instance could be moved from the MapDocument into the Map. For the former I'm not too happy with the duplicated code and instance, and for the latter I'm not too happy about instantiating a renderer at a level where it's not always needed. Maybe it would be enough to create it on-demand.

@bjorn bjorn added the missing feature It's not just a feature, it's a feature that really should be there! label May 3, 2021
@mrmasterplan
Copy link
Contributor Author

It is almost not worth fussing over. This is the workaround I am using for now. https://github.com/MrMasterplan/rwklevelfiles/blob/925111188919081b03ad8c670f797b6c964d739f/tiled/dotkitty/index.ts#L202

@bjorn
Copy link
Member

bjorn commented Jun 2, 2021

Right, in that case the workaround is easy, though it becomes rather more tricky / annoying if you need to support non-orthogonal maps. I'm currently running into this issue while trying to look into MikeMnD/tiled-to-godot-export#26. :-)

@bjorn bjorn closed this as completed in 790e317 Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing feature It's not just a feature, it's a feature that really should be there!
Projects
Archived in project
Development

No branches or pull requests

2 participants