Class Index | File Index

Classes


Class cc.TMXTiledMap


Extends cc.Node.

Defined in: CCTMXTiledMap.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

cc.TMXTiledMap knows how to parse and render a TMX map.

Method Summary
Method Attributes Method Name and Description
<static>  
cc.TMXTiledMap.create(tmxString, resourcePath)
Creates a TMX Tiled Map with a TMX file.
 
getLayer(layerName)
return the TMXLayer for the specific layer
 
map orientation
 
 
getObjectGroup(groupName)
Return the TMXObjectGroup for the secific group
 
object groups
 
properties
 
getProperty(propertyName)
Return the value for the specific property name
 
 
initWithTMXFile(tmxFile, resourcePath)
 
Return properties dictionary for tile GID
 
 
 
 
 
Methods borrowed from class cc.Node:
addChild, cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, ctor, description, draw, getActionByTag, getActionManager, getAnchorPoint, getAnchorPointInPoints, getBoundingBox, getBoundingBoxToWorld, getCamera, getChildByTag, getChildren, getChildrenCount, getContentSize, getGLServerState, getGrid, getOrderOfArrival, getParent, getPosition, getPositionX, getPositionY, getRotation, getScale, getScaleX, getScaleY, getScheduler, getShaderProgram, getSkewX, getSkewY, getTag, getUserData, getUserObject, getVertexZ, getZOrder, ignoreAnchorPointForPosition, init, isIgnoreAnchorPointForPosition, isRunning, isVisible, nodeToParentTransform, nodeToWorldTransform, numberOfRunningActions, onEnter, onEnterTransitionDidFinish, onExit, onExitTransitionDidStart, parentToNodeTransform, pauseSchedulerAndActions, release, removeAllChildren, removeAllChildrenWithCleanup, removeChild, removeChildByTag, removeFromParent, removeFromParentAndCleanup, reorderChild, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setContentSize, setGLServerState, setGrid, setNodeDirty, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setRotation, setScale, setScaleX, setScaleY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, sortAllChildren, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, update, updateTransform, visit, worldToNodeTransform
Class Detail
cc.TMXTiledMap()

cc.TMXTiledMap knows how to parse and render a TMX map.

It adds support for the TMX tiled map format used by http://www.mapeditor.org
It supports isometric, hexagonal and orthogonal tiles.
It also supports object groups, objects, and properties.

Features:
- Each tile will be treated as an cc.Sprite
- The sprites are created on demand. They will be created only when you call "layer.tileAt(position)"
- Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a cc.Sprite
- Tiles can be added/removed in runtime
- The z-order of the tiles can be modified in runtime
- Each tile has an anchorPoint of (0,0)
- The anchorPoint of the TMXTileMap is (0,0)
- The TMX layers will be added as a child
- The TMX layers will be aliased by default
- The tileset image will be loaded using the cc.TextureCache
- Each tile will have a unique tag
- Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
- Each object group will be treated as an cc.MutableArray
- Object class which will contain all the properties in a dictionary
- Properties can be assigned to the Map, Layer, Object Group, and Object

Limitations:
- It only supports one tileset per layer.
- Embeded images are not supported
- It only supports the XML format (the JSON format is not supported)

Technical description:
Each layer is created using an cc.TMXLayer (subclass of cc.SpriteBatchNode). If you have 5 layers, then 5 cc.TMXLayer will be created,
unless the layer visibility is off. In that case, the layer won't be created at all.
You can obtain the layers (cc.TMXLayer objects) at runtime by:
- map.getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
- map.getLayer(name_of_the_layer);

Each object group is created using a cc.TMXObjectGroup which is a subclass of cc.MutableArray.
You can obtain the object groups at runtime by:
- map.getObjectGroup(name_of_the_object_group);

Each object is a cc.TMXObject.

Each property is stored as a key-value pair in an cc.MutableDictionary.
You can obtain the properties at runtime by:

map.getProperty(name_of_the_property);
layer.getProperty(name_of_the_property);
objectGroup.getProperty(name_of_the_property);
object.getProperty(name_of_the_property);

Method Detail
<static> {cc.TMXTiledMap|null} cc.TMXTiledMap.create(tmxString, resourcePath)
Creates a TMX Tiled Map with a TMX file. Implementation cc.TMXTiledMap
//example
var map = cc.TMXTiledMap.create("hello.tmx");
Parameters:
{String} tmxString
{String} resourcePath
Returns:
{cc.TMXTiledMap|null}

{cc.TMXLayer} getLayer(layerName)
return the TMXLayer for the specific layer
Parameters:
{String} layerName
Returns:
{cc.TMXLayer}

{Number} getMapOrientation()
map orientation
Returns:
{Number}

{cc.Size} getMapSize()
Returns:
{cc.Size}

{cc.TMXObjectGroup} getObjectGroup(groupName)
Return the TMXObjectGroup for the secific group
Parameters:
{String} groupName
Returns:
{cc.TMXObjectGroup}

{Array} getObjectGroups()
object groups
Returns:
{Array}

{object} getProperties()
properties
Returns:
{object}

{String} getProperty(propertyName)
Return the value for the specific property name
Parameters:
{String} propertyName
Returns:
{String}

{cc.Size} getTileSize()
Returns:
{cc.Size}

{Boolean} initWithTMXFile(tmxFile, resourcePath)
//example
var map = new cc.TMXTiledMap()
map.initWithTMXFile("hello.tmx");
Parameters:
{String} tmxFile
resourcePath
Returns:
{Boolean}

{object} propertiesForGID(GID)
Return properties dictionary for tile GID
Parameters:
{Number} GID
Returns:
{object}

setMapOrientation(Var)
Parameters:
{Number} Var

setMapSize(Var)
Parameters:
{cc.Size} Var

setObjectGroups(Var)
Parameters:
{Array} Var

setProperties(Var)
Parameters:
{object} Var

setTileSize(Var)
Parameters:
{cc.Size} Var

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:54 GMT-0800 (PST)