Disposing of an object after a RunAction

I am populating a screen with sprites and checking to see if they are tapped on. When they are tapped on, I want to have them fade out and disappear, as well as be removed from memory. Here is my RunAction for the fade:

spriteObject.Sprite.RunAction (new CCFadeOut(0.5));

To get rid of the object, I am doing the following calls immediately after my RunAction call:

spriteObject.RemoveChild (Sprite)
spriteObject.Dispose ();

This doesn't seem to work. The sprite immediately disappears without any fade effect. It appears that the CCFadeOut is getting cancelled out by the Dispose.

I have the following Questions:

1) is this even the correct way to dispose of an object?

2) is there a way to let the sprite object fade naturally and then automatically mark it for disposal after the RunAction has completed?

Best Answer

Answers

  • JaredMathesJaredMathes CAUniversity

    Thanks Kenneth,

    Does the RemoveFromParent() method also dispose of the object from memory or do I need to take care of that separately?

Sign In or Register to comment.