CCFastTMXTiledMap解析

代码:

class CC_DLL TMXTiledMap : public Node
{
public:
    /** Creates a TMX Tiled Map with a TMX file.
     *
     * @return An autorelease object.
     */
	 /// 创建一个TMX 瓦片地图,通过tmx文件
    static TMXTiledMap* create(const std::string& tmxFile);

    /** Initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources. 
     *
     * @param tmxString A TMX formatted XML string.
     * @param resourcePath A path to TMX resources.
     * @return An autorelease object.
     */
	 /// 通过xml创建一个瓦片地图
    static TMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath);

    /** Return the FastTMXLayer for the specific layer. 
     * 
     * @return Return the FastTMXLayer for the specific layer.
     */
	 /// 得到TXMLLayer通过名字
    TMXLayer* getLayer(const std::string& layerName) const;

    /** Return the TMXObjectGroup for the specific group. 
     * 
     * @return Return the TMXObjectGroup for the specific group.
     */
	 /// 得到TMXObjectGroup,通过制定的组
    TMXObjectGroup* getObjectGroup(const std::string& groupName) const;

    /** Return the value for the specific property name.
     *
     * @return Return the value for the specific property name.
     */
	 /// 得到特性的值
    Value getProperty(const std::string& propertyName) const;

    /** Return properties dictionary for tile GID.
     *
     * @return Return properties dictionary for tile GID.
     */
	 /// 通过GID得到特性的值
    Value getPropertiesForGID(int GID) const;

    /** The map's size property measured in tiles. 
     *
     * @return The map's size property measured in tiles.
     */
	 /// 得到地图的尺寸
    inline const Size& getMapSize() const { return _mapSize; };
    
    /** Set the map's size property measured in tiles.
     *
     * @param mapSize The map's size property measured in tiles.
     */
	 /// 设置地图的尺寸
    inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; };

    /** The tiles's size property measured in pixels.
     *
     * @return The tiles's size property measured in pixels.
     */
	 /// 得到瓦片的尺寸
    inline const Size& getTileSize() const { return _tileSize; };
    
    /** Set the tiles's size property measured in pixels. 
     *
     * @param tileSize The tiles's size property measured in pixels.
     */
	 /// 设置瓦片的尺寸
    inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; };

    /** Get map orientation. 
     *
     * @return The map orientation.
     */
	 /// 得到地图的方向
    inline int getMapOrientation() const { return _mapOrientation; };
    
    /** Set map orientation. 
     *
     * @param mapOrientation The map orientation.
     */
	 /// 设置地图的方向
    inline void setMapOrientation(int mapOrientation) { _mapOrientation = mapOrientation; };

    /** Get object groups. 
     *
     * @return Object groups.
     */
	 /// 得到对象组
    inline const Vector<TMXObjectGroup*>& getObjectGroups() const { return _objectGroups; };
    inline Vector<TMXObjectGroup*>& getObjectGroups() { return _objectGroups; };
    
    /** Set object groups. 
     *
     * @param groups An object groups.
     */
	 /// 设置对象组
    inline void setObjectGroups(const Vector<TMXObjectGroup*>& groups) {
        _objectGroups = groups;
    };
    
    /** Get properties.
     *
     * @return Properties.
     */
	 /// 得到所有的属性
    inline const ValueMap& getProperties() const { return _properties; };
    
    /** Set properties. 
     *
     * @param properties An ValueMap Properties.
     */
	 /// 设置属性
    inline void setProperties(const ValueMap& properties) {
        _properties = properties;
    };
/// 得到描述
    virtual std::string getDescription() const override;

protected:
    /**
     * @js ctor
     */
    TMXTiledMap();
    /**
     * @js NA
     * @lua NA
     */
    virtual ~TMXTiledMap();

    /** initializes a TMX Tiled Map with a TMX file */
	/// 初始化
    bool initWithTMXFile(const std::string& tmxFile);

    /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
	/// 初始化
    bool initWithXML(const std::string& tmxString, const std::string& resourcePath);
    
	/// 解析tmx
    TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
    TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
    void buildWithMapInfo(TMXMapInfo* mapInfo);

    /** the map's size property measured in tiles */
    Size _mapSize;
    /** the tiles's size property measured in pixels */
    Size _tileSize;
    /** map orientation */
    int _mapOrientation;
    /** object groups */
    Vector<TMXObjectGroup*> _objectGroups;
    /** properties */
    ValueMap _properties;
    
    //! tile properties
    ValueMapIntKey _tileProperties;

private:
    CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap);

};



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值