Class cc.TMXMapInfo

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.TMXMapInfo(tmxFile, resourcePath)

cc.TMXMapInfo contains the information about the map like:
- Map orientation (hexagonal, isometric or orthogonal)
- Tile size
- Map size

And it also contains:
- Layers (an array of TMXLayerInfo objects)
- Tilesets (an array of TMXTilesetInfo objects)
- ObjectGroups (an array of TMXObjectGroupInfo objects)

This information is obtained from the TMX file.

Method Summary

Class Detail

cc.TMXMapInfo(tmxFile, resourcePath)

cc.TMXMapInfo contains the information about the map like:
- Map orientation (hexagonal, isometric or orthogonal)
- Tile size
- Map size

And it also contains:
- Layers (an array of TMXLayerInfo objects)
- Tilesets (an array of TMXTilesetInfo objects)
- ObjectGroups (an array of TMXObjectGroupInfo objects)

This information is obtained from the TMX file.

1.
//create a TMXMapInfo with file name
var tmxMapInfo = new cc.TMXMapInfo("res/orthogonal-test1.tmx");
2.
//create a TMXMapInfo with content string and resource path
var resources = "res/TileMaps";
var filePath = "res/TileMaps/orthogonal-test1.tmx";
var xmlStr = cc.loader.getRes(filePath);
var tmxMapInfo = new cc.TMXMapInfo(xmlStr, resources);
Parameters:
{String} tmxFile
fileName or content string
{String} resourcePath
If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required.

Field Detail

{String} currentString
- Current string stored from characters stream.
{Object} layerAttrs
- Layer attributes.
{Number} mapHeight
- Height of the map
{Number} mapWidth
- Width of the map
{Number} orientation
- Map orientation.
{Object} parentElement
- Parent element.
{Number} parentGID
- Parent GID.
{Array} properties
- Properties of the map info.
{Boolean} storingCharacters
- Is reading storing characters stream.
{Number} tileHeight
- Height of a tile
{Number} tileWidth
- Width of a tile
{String} tmxFileName
- TMX file name.

Method Detail

  • <static> {cc.TMXMapInfo} cc.TMXMapInfo.create(tmxFile, resourcePath)
    Creates a TMX Format with a tmx file or content string
    Parameters:
    {String} tmxFile
    fileName or content string
    {String} resourcePath
    If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required.
    Deprecated:
    since v3.0 please use new cc.TMXMapInfo(tmxFile, resourcePath) instead.
    Returns:
    {cc.TMXMapInfo}
  • ctor(tmxFile, resourcePath)
    Creates a TMX Format with a tmx file or content string
    Constructor of cc.TMXMapInfo
    Parameters:
    {String} tmxFile
    fileName or content string
    {String} resourcePath
    If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required.
  • {String} getCurrentString()
    Gets the currentString
    Returns:
    {String}
  • {Object} getLayerAttribs()
    Layer attribute
    Returns:
    {Object}
  • {Array} getLayers()
    Layers
    Returns:
    {Array}
  • {cc.Size} getMapSize()
    Map width & height
    Returns:
    {cc.Size}
  • {Array} getObjectGroups()
    ObjectGroups
    Returns:
    {Array}
  • {Number} getOrientation()
    Gets Map orientation.
    Returns:
    {Number}
  • {Object} getParentElement()
    parent element
    Returns:
    {Object}
  • {Number} getParentGID()
    parent GID
    Returns:
    {Number}
  • {Array} getProperties()
    Properties
    Returns:
    {Array}
  • {Boolean} getStoringCharacters()
    Is reading storing characters stream
    Returns:
    {Boolean}
  • {object} getTileProperties()
    Gets the tile properties.
    Returns:
    {object}
  • {Array} getTilesets()
    tilesets
    Returns:
    {Array}
  • {cc.Size} getTileSize()
    Tiles width & height
    Returns:
    {cc.Size}
  • {String} getTMXFileName()
    Gets the tmxFileName
    Returns:
    {String}
  • {Element} initWithTMXFile(tmxFile)
    Initializes a TMX format with a tmx file
    Parameters:
    {String} tmxFile
    Returns:
    {Element}
  • {Boolean} initWithXML(tmxString, resourcePath)
    initializes a TMX format with an XML string and a TMX resource path
    Parameters:
    {String} tmxString
    {String} resourcePath
    Returns:
    {Boolean}
  • {Element} parseXMLFile(tmxFile, isXmlString)
    Initalises parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file
    Parameters:
    {String} tmxFile
    {boolean} isXmlString Optional, Default: false
    Returns:
    {Element}
  • {Boolean} parseXMLString(xmlString)
    initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string
    Parameters:
    {String} xmlString
    Returns:
    {Boolean}
  • setCurrentString(currentString)
    Set the currentString
    Parameters:
    {String} currentString
  • setLayerAttribs(value)
    Layer attribute
    Parameters:
    {Object} value
  • setLayers(value)
    Layers
    Parameters:
    {cc.TMXLayerInfo} value
  • setMapSize(value)
    Map width & height
    Parameters:
    {cc.Size} value
  • setObjectGroups(value)
    ObjectGroups
    Parameters:
    {cc.TMXObjectGroup} value
  • setOrientation(value)
    Set the Map orientation.
    Parameters:
    {Number} value
  • setParentElement(value)
    parent element
    Parameters:
    {Object} value
  • setParentGID(value)
    parent GID
    Parameters:
    {Number} value
  • setProperties(value)
    Properties
    Parameters:
    {object} value
  • setStoringCharacters(value)
    Is reading storing characters stream
    Parameters:
    {Boolean} value
  • setTileProperties(tileProperties)
    Set the tile properties.
    Parameters:
    {object} tileProperties
  • setTilesets(value)
    tilesets
    Parameters:
    {cc.TMXTilesetInfo} value
  • setTileSize(value)
    Tiles width & height
    Parameters:
    {cc.Size} value
  • setTMXFileName(fileName)
    Set the tmxFileName
    Parameters:
    {String} fileName