Projects > cpp > Issues > Bug #738

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

pass CCSize(width,0) to CCLabelTTF cause the label invisible

Bug #738 [Closed]
walzer@cocos2d-x.org 2011-09-25 19:18 . Updated almost 13 years ago

Reported by Dskobg on QQ.

As this document [[How does CCLabelTTF support line breaks and wrapping]] described, it said that CCLabelTTF can calculate the height automatically when use CCSize(width,0) as initial parameter. But as the matter of fact, CCSize(width, 0) causes the label invisible.

I tried to modify these lines in CCImage_ios.mm

    if (pInfo->width != 0 || pInfo->height != 0)
        {
                dim.width = pInfo->width;
                dim.height = pInfo->height;
        }
        else
        {
                pInfo->width = dim.width;
                pInfo->height = dim.height;
        }

to

        if (pInfo->width != 0 && pInfo->height == 0) {
            dim.height = dim.height * ((int)((dim.width - 1) / pInfo->width) + 1);
            pInfo->height = dim.height;
            dim.width = pInfo->width;
        }
        else if (pInfo->width != 0 || pInfo->height != 0)
        {
                dim.width = pInfo->width;
                dim.height = pInfo->height;
        }
        else
        {
                pInfo->width = dim.width;
                pInfo->height = dim.height;
        }

Now it can works as the wiki described.

walzer@cocos2d-x.org 2011-10-14 00:14
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:a0dae03b1e6a1df1e0ada35a76b2dde68e7d3525.

zhangxm 2011-10-14 02:09
  • Status changed from Resolved to Closed
walzer@cocos2d-x.org 2012-05-25 08:02
  • Project changed from cocos2d-x to cpp
  • Category deleted (1)
  • Target version deleted (cocos2d-1.0.1-x-0.9.2)

Atom PDF

Status:Closed
Start date:2011-09-25
Priority:Normal
Due date:
Assignee:-
% Done:

100%

Category:-
Target version:-