Can't draw...

If I have a CCLabelTTF,and I call the draw function,why doesn’t the label get drawn?

May happen for many reasons:

  • The sprite font is not loaded or located correctly
  • You did not add the label to the scene
  • The label is covered by another object (zOrder problem)
  • The label is not placed inside the visible screen
  • You set visible false on the label
  • You usually call ‘visit()’ instead of ‘draw()’ to draw things

Maybe you can post some code and I can give better advice :slight_smile:

what code can i put here? I just have a cclabelttf that is displayed. When the users touches the screen i change the string and I would like to redraw it right at that moment, since then a function that takes time to process is called, so i would put a “loading” text into the string.

I tried both visit and draw on the cclabelttf itself, the layer, and the scene. None managed to actually redraw it.

If I want to change the text of a CCLabelTTF I would just use the setString function, like:

    CCLabelTTF *label = CCLabelTTF::create();
    label->setString("newString");

Did you try this? :slight_smile:

seriously… you think i didn’t know how to change the string and that was the issue…?

I’m just trying to help, there is no need to be rude.

You are just saying “things are not working” without providing any piece of code, the best I can try is to guess what you are doing wrong.

For what you described, it seems that you are not able to change the text of a CCLabelTTF, and since there is a function for that purpose I assume you messed up somewhere with something very basic, given the lack of context.

It doesn’t matter, solved it by adding code so text is changed, and the function that takes time to process is only called when the main update function is called by cocos2dx.