I have a class that I use to render GUI elements on the screen, this class has a tree structure (with children, parent, and siblings). I created an additional class which allows me to interpolate some values of a GUI element (alpha, and rotation for now), each instance of the class is linked to one GUI element (which is updated by it) like this:
// Creating a simple empty cube GUIElem img(0, 0, 40, 40); // Creating an interpolation for img, to rotate it to 90° RotationInterpolation inter(&img, 90); // Inside the loop // This calculates the interpolations from 0° to 90° and updates the image inter.update(delta_time); // This draw the image img.draw();
This is how it looks now, but I want to implement interpolations inside GUIElem methods (
setAlpha()), and I was wondering what is the best method to do it, I came up with two solutions:
- Create a list of interpolations for each
GUIElemand manage them (update, delete) inside GUIElem's
- Create a global list of interpolations and manage it in my loop before rendering
Since pretty much all of my interpolations would be added and deleted continuosly, I'm not sure about which of those methods is more efficient in terms of memory and performance (I could have a lot of GUIElem with no interpolations running but still in need to be checked).