interval question

How to remove interval from memory and how to clear transforms done to a model by it?

Calling either ival.pause() or ival.finish() will stop the interval and prevent it from further influencing the model (until you call ival.start() again). The two methods have slightly different behavior; the former leaves the interval in its current, indeterminate state; the latter sets the interval to its final state.

You can then apply any transforms to the model you like. If you want to remove the interval from memory, simply remove any references you are holding to it.

David

Thank you

Is there a method to set it to it’s beginning state?

ival.remove() , ival.removeNode()?

You can simply call pause() followed by setT(0).

No, just remove the references to the interval. Meaning you should assign the variables that point to it to None, or something like that.

Thanks.
I guess I might as well ask how to remove other objects from memory:
NodePaths -

.remove()

PandaNode (Model, Light…) -

.removeNode()

textfile -

.close()

tasks -

taskMgr.remove('MyTaskName')

onscreentext -

.destroy()

onscreenimage -

.destroy()

Is this right?
what about sounds?

I’m still interested in this.
For example .remove() seems to give the same result for DirectGUI objects as .destroy() visually…

It’s generally the right idea, though there seems to be a bit of confusion between remove() and removeNode() in your text above. NodePath.removeNode() is the normal way to disconnect and remove a node (which you access via a NodePath). Since a NodePath is a handle to a node, it doesn’t make sense to talk about nodes in the absence of NodePaths.

DirectGui should be removed with destroy(), not removeNode(). You can call removeNode() and remove the object from the screen visually, but it will leave its messenger hooks active, which could cause problems for you later.

Sounds don’t have to be explicitly removed. You can just drop them.

David

Thanks again

Yeah, id did crash my program before…

Drop them?

So

NodePaths -

.removeNode()

PandaNode (Model, Light…) -

.removeNode()

textfile -

.close()

tasks -

taskMgr.remove('MyTaskName')

intervals -

intervalName = None

onscreentext -

.destroy()

onscreenimage -

.destroy()

DirectGUI elements -

.destroy()

Right?

Approximately right. I can’t say it’s definitively right, because a lot of this depends on precisely what you mean by “remove”.

For instance, dropping an interval by assigning its variable to None is appropriate if the interval isn’t playing. If the interval is currently playing and you want it to stop immediately, you should call finish() or pause() first.

David