TextCandy: "This is not a Text FX object" message during scene transitions

Hi,

I’m running into an issue with TextCandy under the latest version of Corona.  It has to do with cleaning up during a Composer scene transition.  In a nutshell, I have a menu scene in which I have a TC object.  In the destroy() method of the scene I’m trying to clean it up with:

textCandy:DeleteText(self.textChallenge);

self.textChallenge = nil;

Now, I’ve confirmed that self.textChallenge is a valid reference by doing a simple print(self.textChallenge) which shows a table ID as expected.  I’ve also confirmed that self.textChallenge.name has a value of “FXText” since I saw in the TC code that’s how it determines if it’s a TC object or not.  In other words, the object I’m passing to DeleteText() looks to be exactly what’s expected.

However, this DeleteText() call results in this message:

!!! TextFX:DeleteText(): THIS IS NOT A TEXT FX OBJECT.

I’m of course worried that this will produce a memory leak since I’m doing this with a number of scenes that all contain quite a few TC objects.  The problem is I want to destroy each scene along the way, I don’t want to maintain anything in memory… If I do configure Composer to not recycle scenes then the issue doesn’t occur, but that’s only because destroy() never gets called.

I’ve also tried doing all of this cleanup in the hide() method instead, and I’ve tried it in  both the “will” and “did” phases and the same thing happens in either case.

Does anyone have any idea what I might be doing wrong?  I’m really at a loss to explain this and I’ve been banging my head against the wall for a while on this now.

Thanks,

Frank


Frank W. Zammetti

Author of “Pro iOS and Android Apps for Business”

and “Learn Corona SDK Game Development”

and “Practical Palm Pre webOS Projects”

and “Practical Ext JS Projects with Gears”

and “Practical Dojo Projects”

and “Practical DWR 2 Projects”

and “Practical JavaScript, DOM Scripting and Ajax Projects”

and “Practical Ajax Projects with Java Technology”

(ugh, we get the point, you write A LOT!)

Creator of the mobile game Engineer (www.etherient.com)

For all things me, visit www.zammetti.com

I use Text Candy also. I personally don’t even use textCandy:DeleteText i remove Text Candy objects like this:

if(  LoadLevelScene.ScoreText ~= nil ) then
         LoadLevelScene.ScoreText:delete()
         LoadLevelScene.ScoreText = nil
  end

As far as when to destroy your objects, did you just switch over to composer? I had problems also when destroying Text Candy and Particle Candy when I migrated to composer… lets say your composer scene is  “menu.lua” I personally put everything that needs to be cleaned up in the scene:destroy( event )…

…and then I just call the composer.removeScene(“menu”) in the scene:hide  “did” phase

Hope this helps.

Thanks for that reply.  I actually solved this a few hours ago finally, and wouldn’t you know it was a stupid programmer trick!

The problem was I was calling DeleteText with colon notation rather than dot notation.  It makes sense that it wouldn’t work once you realize that: the unlisted argument self was inserted and the TC code was trying to delete that and correctly reporting that it wasn’t a TC object… and since I was print()'ing the TC object before the call I never noticed because it looked like I *was* passing the right object.

I actually didn’t realize I could just call delete() on the TC objects themselves, I noticed that during my debugging, and that’s probably a bit cleaner way to do it if for no other reason than it looks a lot more like cleaning up other DisplayObjects via removeSelf()… but either way works now once I got past my own stupidity :slight_smile:

As for the composer events, things seem to work as expected there… I do all the cleanup in destroy() like you’re really supposed to and it’s fine… at one point I thought the events might have been firing out of order but the problem there was I was using DeleteTexts() to clean up, which of course was deleting the TC objects on the *new* scene too, and for a while that didn’t occur to me. D’oh!

So yeah, this all boiled down to me having not done any Corona/Lua coding in over a year and just needing to get back into the swing of it :slight_smile:

I use Text Candy also. I personally don’t even use textCandy:DeleteText i remove Text Candy objects like this:

if(  LoadLevelScene.ScoreText ~= nil ) then
         LoadLevelScene.ScoreText:delete()
         LoadLevelScene.ScoreText = nil
  end

As far as when to destroy your objects, did you just switch over to composer? I had problems also when destroying Text Candy and Particle Candy when I migrated to composer… lets say your composer scene is  “menu.lua” I personally put everything that needs to be cleaned up in the scene:destroy( event )…

…and then I just call the composer.removeScene(“menu”) in the scene:hide  “did” phase

Hope this helps.

Thanks for that reply.  I actually solved this a few hours ago finally, and wouldn’t you know it was a stupid programmer trick!

The problem was I was calling DeleteText with colon notation rather than dot notation.  It makes sense that it wouldn’t work once you realize that: the unlisted argument self was inserted and the TC code was trying to delete that and correctly reporting that it wasn’t a TC object… and since I was print()'ing the TC object before the call I never noticed because it looked like I *was* passing the right object.

I actually didn’t realize I could just call delete() on the TC objects themselves, I noticed that during my debugging, and that’s probably a bit cleaner way to do it if for no other reason than it looks a lot more like cleaning up other DisplayObjects via removeSelf()… but either way works now once I got past my own stupidity :slight_smile:

As for the composer events, things seem to work as expected there… I do all the cleanup in destroy() like you’re really supposed to and it’s fine… at one point I thought the events might have been firing out of order but the problem there was I was using DeleteTexts() to clean up, which of course was deleting the TC objects on the *new* scene too, and for a while that didn’t occur to me. D’oh!

So yeah, this all boiled down to me having not done any Corona/Lua coding in over a year and just needing to get back into the swing of it :slight_smile: