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

margin seems to be ignored #443

Closed
max-vogler opened this issue Jun 27, 2023 · 5 comments · Fixed by #444
Closed

margin seems to be ignored #443

max-vogler opened this issue Jun 27, 2023 · 5 comments · Fixed by #444
Labels

Comments

@max-vogler
Copy link

Steps to Reproduce

Import a Tiled map using a Tiled tileset loading a single image with a margin (e.g. 8 pixels of blank space around the tiles, don't confuse with spacing between the tiles).

Expected Result

excalibur-tiled should load the tileset correctly.

Actual Result

excalibur-tiled loads the tiles in a garbled way, some are transparent, some are the wrong tiles.

Environment

  • browsers and versions: Chrome 114
  • operating system: macOS 13
  • Tiled version: 1.10, 1.09
  • Excalibur versions: 0.27.0
  • Tiled plugin versions: 0.27.0
  • (anything else that may be relevant)

Current Workaround

Creating a new tileset in Tiled without margin works.

@eonarheim
Copy link
Member

@max-vogler Thanks for the issue! Definitely unexpected

Is this the margin you're setting in Tiled?

image

@eonarheim eonarheim added the bug label Jun 27, 2023
@max-vogler
Copy link
Author

Yes, exactly! Excuse the short bug report without code/reproduction. My problem was solved after re-doing the tileset without margin and I don't see margin being used in the plugin code.

@eonarheim
Copy link
Member

Hopefully a quick fix 🤞 I distinctly remember writing this type of thing for spritesheets in the main repo

@eonarheim
Copy link
Member

@max-vogler Think I've got this figured! Excalibur uses the same words as Tiled for different things haha! Also we were note interpreting Tiled's concept of margin into Excalibur.

eonarheim added a commit that referenced this issue Jun 29, 2023
Closes #443 

TODO:
* [x] Tests


Tiled and Excalibur use the same words for different things 🤦
 * Tiled tileset `margin` is the same as Excalibur's `SpriteSheet.originOffset`
 * Tiled tileset `spacing` is the same as Excalibur's `SpriteSheet.margin`

Uploaded a Tiled example that demonstrates this in the plugin

<img width="320" alt="image" src="https://github.com/excaliburjs/excalibur-tiled/assets/612071/60844efe-929a-438a-9ea5-01540130d99c">

<img width="414" alt="image" src="https://github.com/excaliburjs/excalibur-tiled/assets/612071/f3daa2e1-fd2d-487e-b2bb-2146c5002933">
@max-vogler
Copy link
Author

Hey thank you so much for the quick fix, love the fast turnaround time! I left a short comment in 0fe3031#r120139294, because I think there might still be a bug related to applying Tiled margin on the right and bottom side, which is not captured by Excalibur's originOffset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants