TextCandy - Text disappearing

In my current app I have the players current score at the top of the screen which is updated as the score increases.  At the moment it is a standard text object, but I’m trying to use TextCandy to animate it to make it more interesting.  The problem I’m having is that the text appears as expected but then disappears about a second later and I can find no reason at all why it is doing this.  I have other TextCandy objects being used which work perfectly so I can’t see why this one isn’t.

The textcandy object is initialised thus…

[lua]

      local scoreDisplay=display.newGroup()

      menuGroup:insert(scoreDisplay)

      – score

      local myScore=TextCandy.CreateText({

          fontName    =   “menuFont”,

          x           =   _w/2,

          y           =   150,

          text        =   “000000”,

          originX     =   “CENTER”,

          originY     =   “CENTER”,

          textFlow    =   “CENTER”,

          charSpacing =   -5

        })

      scoreDisplay:insert(myScore) 

[/lua]

I’ve deleted the animation code for it so that it is just static to see if that makes a difference but it doesn’t, and I’ve even commented out all of the other TextCandy stuff to see if there’s a conflict but the text still disappears.

Help!

This should work without any problems.

  1. Did you ensure that menuGroup, as well as scoreDisplay are positioned within the visible screen area?

  2. To test this, you could create a simple rectangle and insert it to scoreDisplay. Set it’s position to the same position than the text (x = _w/2, y = 150) . Does the rectangle show up?

  3. If the rectangle shows up, you are probably accessing the text anywhere else in your code (changing it’s position, visibility etc.)

Many thanks for the reply.  I have actually worked out what was happening.  I had a number of TC objects on my menu screen and when the scene is changed (using Director) it calls the ‘clean’ function in which i dispose of the texts.  The problem was that the new scene was loading before TC had finished removing all of the text objects so the Score object was being created but then removed as part of the cleanup process that hadn’t finished.  I just worked around it by putting in a small delay before creating the score TC object.  Hope that makes sense.

This should work without any problems.

  1. Did you ensure that menuGroup, as well as scoreDisplay are positioned within the visible screen area?

  2. To test this, you could create a simple rectangle and insert it to scoreDisplay. Set it’s position to the same position than the text (x = _w/2, y = 150) . Does the rectangle show up?

  3. If the rectangle shows up, you are probably accessing the text anywhere else in your code (changing it’s position, visibility etc.)

Many thanks for the reply.  I have actually worked out what was happening.  I had a number of TC objects on my menu screen and when the scene is changed (using Director) it calls the ‘clean’ function in which i dispose of the texts.  The problem was that the new scene was loading before TC had finished removing all of the text objects so the Score object was being created but then removed as part of the cleanup process that hadn’t finished.  I just worked around it by putting in a small delay before creating the score TC object.  Hope that makes sense.