AgreeableDeerGames / GameBackbone

2D game framework
MIT License
11 stars 4 forks source link

CompoundSprite should inherit from sf::Transformable privately #272

Open lavinrp opened 3 years ago

lavinrp commented 3 years ago

Describe the bug It is currently a bug to treat GB::CompoundSprite as a sf::Transformable pointer or reference. Doing so and performing any transforms will move the CompoundSprite without updating any of its components.

To Reproduce Steps to reproduce the behavior:

  1. Create a GB::CompoundSprite
  2. Add a sf::Sprite component to the GB::CompoundSprite
  3. Create a sf::Transformable* pointing to the GB::CompoundSprite
  4. Move the GB::CompoundSprite through the sf::Transformable*
  5. Note that the GB::CompoundSprite has not updated its components

Expected behavior Any time the GB::CompoundSprite moves it should update its components. Since sf::Transformable does not provide virtual functions the best we can do here is not compile.

Additional context Since we will often want some level of polymorphism over transformables we should provide a GB::Transformable concept / type trait. Perhaps it would be worth making our transformable wrapper from CompoundSprite public too.

lavinrp commented 3 years ago

@gyurgyma This is actually pretty bad, so I'm putting it as part of our short 0.4.2 sprint.

We should put the work mentioned under "Additional Context" into its own feature request. That can be pushed back to a later sprint if we want.