Closed ultimate1112 closed 3 years ago
If you're viewing this, feel free to add more to the list of broken sprites.
Ughh... this bug took me down a rabbit hole... Anyway the bug fix should be in the pull request #264.
tl;dr entities considered "unlit" were registered to two different renderers at the same time and was only removed in one renderer when changing levels, i.e. the black squares were old unlit entities.
The problem was that the renderableComponent called the setLit() function on create(), however the create method only gets called when the entity is registered to the entityService. The setLit() call would therefore override any unlit() method calls that happen before the entity was registered (for example any unlit() calls within the entities respective factory). This causes the unlit() method to be called first causing it to be registered to the unlit renderer, and then the setLit() method was called which registered it to the lit renderer and set the "lit" variable to true in renderableComponent. When being disposed the renderableComponent would see the "lit" variable is now true and only remove from the lit renderer. The black squares were each entity that was unlit still being rendered in the next level, except their texture had already been disposed, so they were just a black square.
There is a recurring issue where some assets in the game, specifically Level 2 and Level 3, have black boxes over assets. Think this has to do with the sprite generation and lighting system.
A not-comprehensive list of assets that have this issue:
Level 2: Trees
Level 2: Enemy bullet