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

parse images on each layer individually for native parser, add toggleLayer() #243

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mattjennings
Copy link
Contributor

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

This is a very rough initial implementation to toggle layers during runtime (only for native parser, not sure yet how it would be done for JSON). Personally I only need it for the native parser.

Notable changes are each frame on each layer is parsed on their own canvas ctx in order to be drawn individually.

Linked cells need to be tested, not sure if I broke those. The integration test failed for me with minor(?) pixel diffs, so may just be from running on a macbook.

diff-actual

Closes #242

Changes:

add toggleLayer(name, visible) function to resource
@eonarheim
Copy link
Member

@mattjennings This is an awesome idea! 🎉 100% down

@eonarheim
Copy link
Member

I'll run the pixel tests locally to see if I get the same diff

@eonarheim
Copy link
Member

@mattjennings I checked this locally, AFAIK it looks like a platform rendering difference. I went ahead and switched the image diff to playwright on main too.

@eonarheim
Copy link
Member

This is a very rough initial implementation to toggle layers during runtime (only for native parser, not sure yet how it would be done for JSON). Personally I only need it for the native parser.

I'm okay with this, I don't think anything can be done with the JSON since the export is already flattened. Perhaps a warning here and a no-op?

@eonarheim
Copy link
Member

Sorry for spamming your inbox lol, I see you have an error on JSON type, that's probably okay...

@eonarheim
Copy link
Member

I'm poking around and I think linked cells were just broken in main prior to your change :O

@mattjennings
Copy link
Contributor Author

@eonarheim I was working on resolving the conflicts with latest main but realized my changes actually breakingly change spritesheets, as it parses each layer+frame as an individual sprite. So .getSprite(x,y) will never return a full layer's worth of sprites.

I'm not really sure what the best solution is here. For fun, I tried making a GraphicGroup and using that as the sprite in the Spritesheet() constructor and it seemed to work but I imagine that'll cause other issues.

I wonder if we might need a concept of layering within a Spritesheet.

@eonarheim
Copy link
Member

@eonarheim I was working on resolving the conflicts with latest main but realized my changes actually breakingly change spritesheets, as it parses each layer+frame as an individual sprite. So .getSprite(x,y) will never return a full layer's worth of sprites.

I'm not really sure what the best solution is here. For fun, I tried making a GraphicGroup and using that as the sprite in the Spritesheet() constructor and it seemed to work but I imagine that'll cause other issues.

I wonder if we might need a concept of layering within a Spritesheet.

I was noodling on this, I wonder if we flatten all the layers into 1 image for the purpose of SpriteSheet? Although that does thwart your desire to toggle layers.

Layering a sprite sheet could be interesting... I'll noodle. We could at minimum make a SpriteSheet per layer?

@mattjennings
Copy link
Contributor Author

Yeah unfortunately flattening would kill the layering. The layering is really just done by spitting out a GraphicGroup as the exFrame for the animation.

1 Spritesheet per layer might make sense... then .getSprite() would take an optional layer name. But some people may not want this, so maybe you could opt-in to layering as a resource option? I feel like it's getting pretty icky any way we cut it though.

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

Successfully merging this pull request may close these issues.

Toggling layer visibility at runtime
2 participants