Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
Kenneth Pouncey edited this page Aug 21, 2014 · 30 revisions

Labels are a way for the developer to present text to the user.

- Screen shot here

CocosSharp contains 4 types of Labels that can be used.

CCLabelAtlas

This type of label uses a character map atlas to display it's text. The advantages of using this type of label is that it is fast but is not very flexible. This label has been superseded by CCLabelBMFont and is mostly used to maintain backwards compatibility. For instance CCStats.cs, for displaying the statistics, uses a CCLabelAtlas with an embedded image file.

- Screen shot here

CCLabelBMFont

This type of label uses a Bitmap Font generated by an external program which consists of an image file and a character map configuration file.

  • The bitmap (image) can be customized with graphics editors.
  • The label can be updated without penalty. Internally the label uses a SpriteBatchNode so changing the text is just a matter of making the specific image of the character visible or not.
  • It is very flexible. Each letter of the label can be treated as it's own specific object. Thus you can attach CCActions to each character to create interesting effects.
  • Supports Kerning
  • Are only the size that the spritefont specifies and is not dynamic. This means if you want a specific font at 38 point size and 24 point size you will have to generate and include both in your package.
  • Can be used on all supported platforms

- Screen shot here

CCLabelTtf

Even though this type of label hints at being a label that displays .TTF (True Type Fonts) it actually does not have anything to do with TTF at all. This label type is a wrapper around an XNA/MonoGame spritefont resource.

  • Can use the numerous .xnb spritefont resources that you can find.
  • Can create your own using the XNA Content Pipeline or MonoGames Gui Content Pipeline with the caveat that these are unfortunately Windows only for now. MonoGame has an experimental Mac version as well.
  • Sometimes difficult to use. For instance iOS has to be generated differently than the other platforms due to the way the underlying image needs to be presented.
  • Supports Kerning
  • Are only the size that the spritefont specifies and is not dynamic. This means if you want a specific font at 38 point size and 24 point size you will have to generate and include both in your package.
  • Can be used on all supported platforms.

- Screen shot here

CCLabel

This label uses the fonts that are supplied on the platform you are targeting. A .ttf font can be used as well by including it with the application.

  • The bitmap (image) can be customized with graphics editors.
  • The label can be updated without penalty. Internally the label uses a SpriteBatchNode so changing the text is just a matter of making the specific image of the character visible or not.
  • Fast because it uses a SpriteBatchNode the same as CCLabelBMFont but only the characters that are specified are generated instead of one large Bitmap. The character map image is generated on the fly when a specific character image is needed.
  • It is very flexible. Each letter of the label can be treated as it's own specific object. Thus you can attach CCActions to each character to create interesting effects.
  • Supports Kerning
  • The fonts can be any size that you specify and will be generated on the fly.
  • Developer has to be careful because not all fonts exist on all platforms.
  • The .TTF needs to be delivered with the application and may have copyrights.
  • The fonts generated can look different per platform even though the same font is used. This is due to the underlying graphics rendering of each platform.
  • Supported on all platforms except Windows Phone

- Screen shot here

Clone this wiki locally