首先创建label: gameScoreLabel = CCLabelTTF::create("0", "Arial", 30); gameScoreLabel-setColor(ccRED); gameScoreLabel-retain(); gameScoreLabel-setPosition(ccp(s.width / 6, s.height / 6) ); this-addChild(gameScoreLabel, 1); 根据分数增
首先创建label:
gameScoreLabel = CCLabelTTF::create("0", "Arial", 30);
gameScoreLabel->setColor(ccRED);
gameScoreLabel->retain();
gameScoreLabel->setPosition(ccp(s.width / 6, s.height / 6) );
this->addChild(gameScoreLabel, 1);
根据分数增加:
m_iGamScore++; //
char str[100] = {'0'};
sprintf(str, "%d", m_iGamScore);
gameScoreLabel->setString(str);
gameScoreLabel->setVisible(true);
还可以做成。让鼠标点击在哪里,它就追随到哪里:
CCPoint point = touch->locationInView();
CCMoveTo *move = CCMoveTo::create(1, point); //创建一个Action
gameScoreLabel->runAction(move);//执行这个Action