本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-X 节点(CCLabelAtlas.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
///cocos2d-x-3.0alpha0/cocos2dx/label_nodes

#ifndef __CCLABEL_ATLAS_H__
#define __CCLABEL_ATLAS_H__

#include "base_nodes/CCAtlasNode.h"

NS_CC_BEGIN

/**
 * @addtogroup GUI
 * @{
 * @addtogroup label
 * @{
 */

/** @brief LabelAtlas 是 AtlasNode 的子类.

他的速度很快可以替代标签.

LabelAtlas 相对于 Label:
- LabelAtlas 比 Label 要快
- LabelAtlas "characters" 有一个固定的宽度和高度       //字符
- LabelAtlas "characters" 可以是任何你想要的,因为它们是从一个文件演变过来的

 LabelBMFont 是一个更灵活的类. 它支持可变宽度的字符,也有一个很好的编辑器.
*/
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
{
public:
    /**
     * @js ctor
     */
    LabelAtlas()
        :_string("")
    {}
    /**
     * @js NA
     * @lua NA
     */
    virtual ~LabelAtlas()
    { 
        _string.clear(); 
    }

    /** 使用 字符串、一个 char map 文件(the atlas)、每个元素的宽度、每个元素的高度、 atlas 的起始字符 创建一个 LabelAtlas ,  */
    static LabelAtlas * create(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
    
    /** 使用字符串、一个配置文件 创建一个 LabelAtlas
     @since v2.0
     */
    static LabelAtlas* create(const char *string, const char *fntFile);

    /** 使用 字符串、一个 char map 文件(the atlas)、每个元素的宽度、每个元素的高度、 atlas 的起始字符 初始化一个 LabelAtlas*/
    bool initWithString(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
    
    /** 使用字符串、一个配置文件 初始化一个 LabelAtlas
     @since v2.0
     */
    bool initWithString(const char *string, const char *fntFile);
    
    /** 使用字符串、一个 texture、每个元素的宽度和高度(以像素为单位、 atlas 的起始字符 初始化一个 LabelAtlas */
    bool initWithString(const char* string, Texture2D* texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
    
    // super methods
    virtual void updateAtlasValues();
    virtual void setString(const char *label);
    virtual const char* getString(void) const;
    
#if CC_LABELATLAS_DEBUG_DRAW
    virtual void draw();
#endif

protected:
    // string to render
    std::string _string;
    // the first char in the charmap
    unsigned int _mapStartChar;
};

// end of GUI group
/// @}
/// @}


NS_CC_END

#endif //__CCLABEL_ATLAS_H__




Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐