CCLabelAtlas,CCLabelTextFormatter解析
2015-09-05 23:54
766 查看
代码:
/** * @class LabelAtlas * @brief LabelAtlas is a subclass of AtlasNode. *LabelAtlas是一个AtlasNode的子类 * It can be as a replacement of Label since it is MUCH faster. * 他可以代替Label,因为他更快 * LabelAtlas versus Label: * - LabelAtlas is MUCH faster than Label. * - LabelAtlas "characters" have a fixed height and width.字符有固定的宽高 * - LabelAtlas "characters" can be anything you want since they are taken from an image file. * 可以是任何的样子,因为他们从图片文件中得到 * A more flexible class is LabelBMFont. It supports variable width characters and it also has a nice editor. *LabelBMFont是一个更灵活的类,支持可变宽度的字符,还有不错的编辑器 */ class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol { public: /** * Creates an empty LabelAtlas. * User need to call initWithString(...) later to make this object work properly. */ // 创建一个LabelAtlas对象 static LabelAtlas* create(); /** Creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas. */ static LabelAtlas* create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); /** * Creates the LabelAtlas with a string and a configuration file. * @since v2.0 */ static LabelAtlas* create(const std::string& string, const std::string& fntFile); /** Initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas. */ // 初始化 bool initWithString(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); /** * Initializes the LabelAtlas with a string and a configuration file. * @since v2.0 */ bool initWithString(const std::string& string, const std::string& fntFile); /** Initializes the LabelAtlas with a string, a texture, the width and height in points of each element and the starting char of the atlas */ bool initWithString(const std::string& string, Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); // 设置文本 virtual void setString(const std::string &label) override; // 得到文本 virtual const std::string& getString(void) const override; // 更新图集的值 virtual void updateAtlasValues() override; /** * @js NA */ virtual std::string getDescription() const override; #if CC_LABELATLAS_DEBUG_DRAW // 绘制 virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; #endif CC_CONSTRUCTOR_ACCESS: LabelAtlas() :_string("") { #if CC_LABELATLAS_DEBUG_DRAW _debugDrawNode = DrawNode::create(); addChild(_debugDrawNode); #endif } virtual ~LabelAtlas() { _string.clear(); } protected: virtual void updateColor() override; #if CC_LABELATLAS_DEBUG_DRAW DrawNode *_debugDrawNode; #endif // string to render std::string _string; // the first char in the char map int _mapStartChar; };
代码:
// @cond DO_NOT_SHOW #include "platform/CCPlatformMacros.h" NS_CC_BEGIN class Label; //标志文本格式画 class CC_DLL LabelTextFormatter { public: // 多重文本 static bool multilineText(Label *theLabel); // 拍成一排 static bool alignText(Label *theLabel); // 创建文本精灵 static bool createStringSprites(Label *theLabel); };
相关文章推荐
- 第45讲:Scala中Context Bounds代码实战及其在Spark中的应用源码解析
- 今天做了修改功能
- 关于绝对路径和相对路径
- redis配置项解释
- Java第一周:1.5
- iOS开发笔记之NSFileManager的使用
- 【7】用Laravel5.1开发一个简单的博客系统
- Linux内核最新的连续内存分配器(CMA)——避免预留大块内存
- linux 文件特殊权限
- Java第一周:1.4
- [Java Concurrency in Practice]第十一章 性能与可伸缩性
- MVC模式和文档/视图结构
- iOS学习8:iOS沙盒(sandBox)机制(二)之沙盒文件操作
- 基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用
- 数据库课程设计
- 转:iOS-CoreLocation:无论你在哪里,我都要找到你!
- as3.0-----计时器的使用实例
- python对象的比较(is,==,对象大小比较>,<)
- hdu 4960 Another OCD Patient(动态规划)
- CCLabel解析