AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 289 forks source link

Refactor Anim/SpriteRenderer #439

Closed ilexp closed 7 years ago

ilexp commented 7 years ago

Summary

Having AnimSpriteRenderer derive from SpriteRenderer is bad design from a component-based perspective and annoying when introducing a new subclass, as there always have to be two of them - one animated and one not. To fix this, get rid of AnimSpriteRenderer entirely and let SpriteRenderer expose a sprite index property.

Analysis

ilexp commented 7 years ago

Note: Should the basic SpriteRenderer already expose properties for two simultaneously displayed, blended frames and just ignore them, while subclasses may use that functionality?

Note: Alternatively, should there be an interface between SpriteRenderer and SpriteAnimator that exposes these properties, which is used instead of a direct SpriteRenderer implementation?

If none of the above was implemented, this new design would be limited to hard, instantaneous switches between a finite number of animation states, which is likely insufficient in some advanced cases such as smooth animation. It would also be possible to introduce a new SpriteIndexBlend struct with two indices and a float blend.

Note: Should the API be consciously limited to hard, instantaneous switches as described above?

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Note: Consider getting rid of SpriteIndexBlend completely, as flipbook animation is just the way more common case and the smooth animation sample can do a custom subclass implementation of both renderer and animator. This would simplify a lot of things, including user experience / learning.

When doing this, update FlapOrDie and DualStickSpaceShooter accordingly.

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Moved RequiredComponent extension to issue #464.

ilexp commented 7 years ago

Progress

Immediate ToDo

ilexp commented 7 years ago

Done.