Skip to content

Toggling layer visibility at runtime #242

@mattjennings

Description

@mattjennings

Context

It would be very handy if it were possible to toggle visibility of certain layers on/off during a game. This should be possible for both native & json file formats as it seems the json export allows you to split the layers.

Proposal

I did a bit of digging through the source, and I think at a high level this might look like:

  • Each sprite is processed per-layer
  • Each frame of an animation is a GraphicsGroup of all visible layers
  • Layers are toggleable from the aseprite resource. Maybe resource.toggleLayer(name, boolean)

Not sure how well this concept of animation frames being a GraphicsGroup fits into the ex.Animation class. Maybe the logic for layering should be done there, and then this plugin would just parse them appropriately.

Caveats

With a json export, the image is exported with split layers is all in 1 image so there is potential for it to get very big with many layers. But with a native resource it seems like the parser writes to a canvas to make the image source, so maybe we could parse each layer as its own image source to keep the texture size low?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions