What is the best way to implement local scores to show on each scene?
Should I use label or AtlasLabel?
I tried to use label and AtlasLabel, but it does not get updated, it just displays zero.
Thanks!
A fast, easy to use, free, and community supported 2D game engine
What is the best way to implement local scores to show on each scene?
Should I use label or AtlasLabel?
I tried to use label and AtlasLabel, but it does not get updated, it just displays zero.
Thanks!
"I tried to use label and AtlasLabel, but it does not get updated, it just displays zero."
Assuming score is an integer, try:
NSString *str = [NSString stringWithFormat:@"%i", score];
[myScoreLabel setString:str];I tried that, it get's updated only after game runs at least once. How can I use something
like cocos fps display where fps stays throughout all game?
Thanks!
You don't want to update the label that often, because changing the label is as expensive as creating a new sprite (unless it's an atlas label). You want to set up an update method and call it only when the score needs to be updated. It will not update automaticslly, you need to call [label setString:yourStringHere] on it every time you want to update it. But definitely do not re-draw it every frame.
Sounds logical, I'll try that.
Thanks!
yes - use AtlasLabel if possible
What I do is that I separated the model (the score) and the view (the label).
The view part has something like:
- step:(ccTime) dt
{
if (previousScore != model.score)
{
NSString *str = [NSString stringWithFormat:@"%i", model.score];
[myScoreLabel setString:str];
}
}
A NSNotification might also be something to look into.
Thanks for suggestions!
I'll try that.
Hi,
I have 10 scenes, each of them has separate interface, I figured it out how to
use labelAtlas to display it, but I'm stuck with implementing update function. Should I create global function to do this?
Please advise.
Thanks!
Thanks, I'll try to do it this way.
May I ask ? when we should use AtlasLabel and when to just use Label? which one is faster and lighter ( consume less memory ).???
Thanks
^ Did you read this ? http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:labels
Basically you use LabelAtlas (or BitmapFontAtlas) to display text that is updated frequently (like score or timer). And Label for text that doesn't change often or at all.
updated score is viewed when i run the game next time. it's not appearing at the run time when it is currently running. any solution?
@apukumarghose mega bump. I use CCBitmapFontAtlas since it doesn't take tons of memory to constantly update.
Where did you find information on what to type in for ... fntFile:@"bitmapFontTest.fnt"];
You must log in to post.