Forum > C++ > CCLabelTTF::labelWithString crashes randomly

CCLabelTTF::labelWithString crashes randomly

By l4u Posted 2011-10-05 07:02 Comments 3
l4u
  • Posts: 54

My game crashes with
CCLabelTTF* label = CCLabelTTF::labelWithString(“No Internet Connection.”, CCSize(100,100), CCTextAlignmentCenter, “Thonburi”, 20);

but when i modify the string, it works.
(in android only)

zhangxm
  • Posts: 2082
  • Location: Xiamen, China

#1 RE: 2011-10-09 01:44

What you said means that, the crash is something about the content of the string.
It is so strange.

huangrh
  • Posts: 171

#2 RE: 2011-10-09 02:58

to Leo Lou:
are you sure it works when you modify that string?

i have tested this on g7.
and it worked well when the font is Marker Felt, but failed when the font is Thonburi, although i modified the string.

maybe Thonburi is not supported by android

feiting_schatt
  • Posts: 11

#3 RE: 2012-05-07 16:26

This happens a lot, and often crashes at seemingly different spots, always one of three.

The arrayMakeObjectsPerformSelector area,
a CCTouch callback,
or somewhere on the label creation.

If you allocate a lot of labels, or your scenes have them in general, chances are you’ll crash a lot. I can run for 5 min. sometimes and 1 second other times.

It’s hard to trace since it’s usually buried in system calls after setNextScene, within the touches callbacks. Now, any good tutorials on using a BMFont? The official cocos2d tutorial (not 2d-x) tries, but their grammar states “A or B, A is outdated, let’s use A”.. anywho, seems to be “the fix” for those

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps