Hi, I have a question or two about how best to remove my intervals when I am done with them.
Right now, I create and add intervals to a CMetaInterval on the fly in response to events. Sometimes I can clear the intervals that have already run using metainterval->clear_intervals() before I create new ones. However, sometimes I cannot do this as I need to create and queue intervals at different times. So my question is this…how can I get an interval to destroy itself (remove itself from the metainterval) as soon is it finishes playing? It looks like there should be some way to do this using the finalize or autofinish methods, but I can’t seem to figure it out.
Also, just out of curiosity, the API says to call get_next_event() and get_next_removal() after calling step() in the interval manager. I do not seem to need to do this. I do need to call step to get intervals to play, but the next and remove functions don’t seem to do anything and always return -1 when I use them. Can someone clarify or explain this briefly.
I appreciate the help, you guys rule.
Actually, you’re not supposed to be able to modify a playing interval on-the-fly like that. It might happen to work now, but you’re relying on undocumented behavior, and it might stop working in the future. If you want to start playing an interval in response to a dynamic event, you should add it as a separate interval to the IntervalManager. (And then it becomes trivial to remove it when you’re done.)
The get_next_event() stuff is designed to support Python-based intervals. If all of your intervals are defined in C++, then get_next_event() will always return -1.
I don’t think I explained that clearly enough.
I am currently creating new intervals in a function, based on the parameters passed in. I add these to a cmetainterval and start it, calling step() in the manager once a frame to play them.
I think this is what you are describing, but what is the correct way to remove these intervals from the cmetainterval when they finish?
Right now I clear the metainterval in the same function before I create and add new ones, essentially replacing the intervals with new ones. The issue is that sometimes I need to create and add the new intervals without clearing the old ones, but I want them all to be removed when they finish playing.
Basically, the issue is that I don’t know how to automatically or explicitly remove intervals that have finished playing from a metainterval.
You’re not supposed to use the CMetaInterval as a dynamic repository to add and remove intervals to. You’re supposed to create a CMetaInterval and add a bunch of intervals to it at construction time. Once you have started playing it, you’re not supposed to modify it thereafter.
There should be no reason to do this, though. Anything you can do via CMetaInterval, you can do just as easily with the IntervalManager.