ios - How to truncate label in cocos2dV3.0 -


i trying truncate label when text becomes large instead got expanded center moving left side.

this snippet.

 cclabelttf *playerlabel = [cclabelttf labelwithstring:[nsstring stringwithformat:@"playerdadsadsd %d",i+1] fontname:@"helvetica-bold" fontsize:fontsize];          playerlabel.color =  playercolor;         playerlabel.name = [nsstring stringwithformat:@"%d",1002+i];         playerlabel.position = ccp(playersprite.position.x + playersprite.contentsize.width + 10, ypos);         playerlabel.adjustsfontsizetofit = yes;         [self addchild:playerlabel]; 

enter image description here

i'm not sure trying achieve, try passing dimensions parameter init method:

//the label won't go out of rectangle cgsize rect = cgsizemake(viewsize.width * 0.1f, viewsize.height * 0.1f);  nsstring *text = [nsstring stringwithformat:@"playerdadsadsd %d",i+1]; cclabelttf *playerlabel = [cclabelttf labelwithstring: text                                               fontname: @"helvetica-bold"                                              fontsize: fontsize                                            dimensions: rect]; // <-- note parameter  //.. rest of code.. 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -