cocos2d-x and app42 scoreboard problem

0 votes
I've been debugging this for a week already, but I can seem to find an answer to this problem I posted in cocos2d-x forum

http://discuss.cocos2d-x.org/t/label-setstring-problem/20199

I wan't to show an App42 player's score on label ttf, but it's messed up. And I can say that this is related to App42 because if I remove App42 and use my local data or static variable it will work fine.
asked Feb 27, 2015 in App42 Cloud API-BaaS by jvfiel (35 points)
Hi,
Can you provide some more details like how you are creating the label and setting the value to the label? It will help to debug the problem.
in my Init()

upper_right_layer = Layer::create();
upper_right_layer->ignoreAnchorPointForPosition(false);
upper_right_layer->setContentSize(Size(winSize.width,winSize.height));
upper_right_layer->setAnchorPoint(Vec2(0.5,0.5));
upper_right_layer->setPosition(Point(winSize.width/2,winSize.height/2));
this->addChild(upper_right_layer,1);

top_player= Label::createWithTTF("TOP #1:","TitilliumWeb-Black.ttf",fontsize);
top_player->enableGlow(Color4B(0,0,255,255));
SCALENODE_XY(top_player);
top_player->setColor(textcolor);
top_player->setPosition(Vec2(winSize.width-top_player->getBoundingBox().size.width/2,winSize.height-top_player->getBoundingBox().size.height/2));
upper_right_layer->addChild(top_player,1);

int max_query = 1; //1 since I want to get the top #1 player only

scoreBoardService->GetTopNRankers(gameName.c_str(), max_query, app42callback(MainMenu::onScoreBoardRequestCompleted, this));

in my onScoreBoardRequestCompleted

App42GameResponse *scoreResponse = (App42GameResponse*)response;
CCLog("\ncode=%d",scoreResponse->getCode());
CCLog("\nResponse Body=%s",scoreResponse->getBody().c_str());

if (scoreResponse->isSuccess)
{
    vector<App42Score> scores = scoreResponse->scores;
    for(std::vector<App42Score>::iterator it = scores.begin(); it != scores.end(); ++it)
    {
        CCLog("\n CreatedAt=%s",it->getCreatedOn().c_str());
        CCLog("\n Rank=%0.0lf\n",it->getRank());
        CCLog("\n ScoreId=%s\n",it->getScoreId().c_str());
        CCLog("\n ScoreValue=%f\n",it->getScoreValue());
        CCLog("\n UserName=%s\n",it->getUserName().c_str());
        CCLog("\n Facebook Id = %s",it->facebookProfile.getFbId().c_str());
        CCLog("\n Facebook Picture URL = %s",it->facebookProfile.getPicture().c_str());

        if(max_query==1) //1 player only
        {
                        top_player->setString( it->getUserName());
            break;
        }
    }
}
else
{
    CCLog("\nerrordetails:%s",scoreResponse->errorDetails.c_str());
    CCLog("\nerrorMessage:%s",scoreResponse->errorMessage.c_str());
    CCLog("\nappErrorCode:%d",scoreResponse->appErrorCode);
    CCLog("\nhttpErrorCode:%d",scoreResponse->httpErrorCode);
}

1 Answer

+1 vote
Solve! I used Bitmap Fonts instead of TTF, I don't know why, it's really weird but it worked!
answered Feb 28, 2015 by jvfiel (35 points)
Great, I was also trying to reproduce the issue with "Marker Felt" Font that comes with cocos2dx using

userLabel = Label::createWithSystemFont("TOP #1:","Marker Felt",fontsize);

But everything is working fine as i am able to change the text of the label using setString method from the callback "onScoreBoardRequestCompleted".
what cocos2d-x version are you using? mine is 3.3beta
cocos2d-x 3.3
final? beta? or alpha
cocos2d-x 3.3 final
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...