Jump to content
  • Advertisement
Sign in to follow this  
mrmrcoleman

Trigger/Interpolator questions...

This topic is 4742 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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* value
public:
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!