-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Sprite Layer API #322
Sprite Layer API #322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, some takes on this API direction
- So far, we've avoided putting too much logic in
BaseSprite
andBaseScene
and I'm not sure I want that to change? (I assume you wantBaseScene.__iter__()
to produce sprites in layer order) BaseScene.define_layer()
is totally against the declarative direction we've been moving in an encouraging- The thing I had been picturing for string layers is just
BaseScene.layers
as a list of strings, and the order in the list defines the order of layers? I guess a dict works but it feels clunkier? Maybe I just don't like it because it's not my idea.
That's definitely true of BaseSprite, I think BaseScene is just a matter of the only functionality we've needed is container and iteration and lookups.
Yes. That's primarily a backwards compatibility thing: We don't have to change renderer logic by making sure I'm going to ponder on the rest of this. I've got ideas. |
ok, so here's the concrete things against implementing ordering in
|
An implementation! Once this is merged, I can start work on both a layering mixin for Sprites and start the work on the Renderer rebuild. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting the render-side changes to be part of this PR, too? Unless you're immediately planning to do a bunch of renderer work at once.
But what I do see is fine.
One last comment: Did we want to add |
That's reasonable. Will add it. |
bors r+ |
322: Sprite Layer API r=astronouth7303 a=pathunstrom Implements a basic layering API. `Sprites` can have a `layer` attribute that should be an integer, but due to implementation details could be a float. Does not change the renderer as part of this change, will do so in a followup PR. This is one step on the way to #276 Proposal: * `BaseScene.sprite_layers()` which returns all sprites based on their layering order. * Layers are simple attributes on `Sprites`. * You can name layers via `BaseScene.named_layers` which will default to incrementing each layer number by 1. * You can have greater control over your layer definition by providing `BaseScene.defined_layers` as Dict[str, int]. * There is a `BaseSprite.default_layer` which a Sprite without a layer attribute defaults to. It can be a string or an int as preferred by the end user. Co-authored-by: Piper Thunstrom <pathunstrom@gmail.com>
Build failed
|
bors retry |
322: Sprite Layer API r=astronouth7303 a=pathunstrom Implements a basic layering API. `Sprites` can have a `layer` attribute that should be an integer, but due to implementation details could be a float. Does not change the renderer as part of this change, will do so in a followup PR. This is one step on the way to #276 Proposal: * `BaseScene.sprite_layers()` which returns all sprites based on their layering order. * Layers are simple attributes on `Sprites`. * You can name layers via `BaseScene.named_layers` which will default to incrementing each layer number by 1. * You can have greater control over your layer definition by providing `BaseScene.defined_layers` as Dict[str, int]. * There is a `BaseSprite.default_layer` which a Sprite without a layer attribute defaults to. It can be a string or an int as preferred by the end user. Co-authored-by: Piper Thunstrom <pathunstrom@gmail.com>
Build succeeded
|
Implements a basic layering API.
Sprites
can have alayer
attribute that should be an integer, but due to implementation details could be a float.Does not change the renderer as part of this change, will do so in a followup PR.
This is one step on the way to #276
Proposal:
BaseScene.sprite_layers()
which returns all sprites based on their layering order.Sprites
.BaseScene.named_layers
which will default to incrementing each layer number by 1.BaseScene.defined_layers
as Dict[str, int].BaseSprite.default_layer
which a Sprite without a layer attribute defaults to. It can be a string or an int as preferred by the end user.