Inheriting from the Sprite Class
Last updated
Was this helpful?
Last updated
Was this helpful?
In general it is not recommended to inherit from the Sprite class. This can reslt in cluttered interfaces and improper instantiation of objects. Instead, we recommend using the for your game objects. However, if you are sure that inheriting from the Sprite class is the only solution to your problem, you can do so by instantiating an object using your derived class, then adding it to the . Assuming DerivedSprite is a class which inherits from the Sprite class, the following code can be used to add a newly created instance of the derived class to the and assign its texture.