Trigger/Interpolator questions...
I have been reading the Enginuity 5 article about triggers and interpolators and I have a couple of questions about how exactly they work.
In my program I have an Screen class which stores a vector of ScreenEntityBase objects which make up the entities within the screens in my UI (Animations/sounds/textures etc). The ScreenEntityBase class itself provides pure virtual methods which are over-ridden by a host of specialisations of the ScreenEntityBase class.
I thought that I could also have a vector of Triggers and Interpolators in the Screen class which could be updated each frame and used to control the behaviours of the ScreenEntity's, my question is...
Say I create an interpolator to control the alpha value of one of the ScreenEntity's in the ScreenEntityList, how do I go about setting the reference in the interpolator to reference a data member of one of the ScreenEntity objects.
I guess what I am asking is, can I have a reference to a data member in another object from an interpolator object?
Thanks for any help on this, if I am not particularly clear feel free to ask questions and I will see if I can explain myself a bit better.
Kind regards,
Mark Coleman
Quote:Original post by mrmrcolemanYes.
I guess what I am asking is, can I have a reference to a data member in another object from an interpolator object?
You could do this:
class Interpolator{ float* valuepublic: Interpolator(float* v) : value(v) {} Update(float delta) { *value += delta; }};class SomeClass{public: float value;};SomeClass* thing = new SomeClass;interpolator_list.push_back(Interpolator(&thing->value));
Just remember that "thing->value" goes away at the same time "thing" goes away - look out for hanging pointers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement