Trigger/Interpolator questions...

Started by
4 comments, last by mrmrcoleman 18 years, 10 months ago
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
Advertisement
Quote:Original post by mrmrcoleman
I guess what I am asking is, can I have a reference to a data member in another object from an interpolator object?
Yes.

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.
Good man! Thank you...

Mark Coleman
One other thing actually... Most of the data members that I will be wanting to interpolate will be private/protected. How can I then go about achieving the same results as above?

Is the best way to make each of these classes 'friends' with the interpolator class?

Thanks again, Mark Coleman.
GetMethods??

Cheers
Chris
CheersChris
Thank you.

This topic is closed to new replies.

Advertisement