Class cc.TMXTiledMap
Extends
cc.Node.
Defined in: CCTMXTiledMap.js.
Constructor Attributes | Constructor Name and Description |
---|---|
cc.TMXTiledMap knows how to parse and render a TMX map. |
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)
|
|
propertiesForGID(GID)
Return properties dictionary for tile GID
|
|
setMapOrientation(Var)
|
|
setMapSize(Var)
|
|
setObjectGroups(Var)
|
|
setProperties(Var)
|
|
setTileSize(Var)
|
- 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
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);
//example var map = cc.TMXTiledMap.create("hello.tmx");
- Parameters:
- {String} tmxString
- {String} resourcePath
- Returns:
- {cc.TMXTiledMap|null}
- Parameters:
- {String} layerName
- Returns:
- {cc.TMXLayer}
- Returns:
- {Number}
- Returns:
- {cc.Size}
- Parameters:
- {String} groupName
- Returns:
- {cc.TMXObjectGroup}
- Returns:
- {Array}
- Returns:
- {object}
- Parameters:
- {String} propertyName
- Returns:
- {String}
- Returns:
- {cc.Size}
//example var map = new cc.TMXTiledMap() map.initWithTMXFile("hello.tmx");
- Parameters:
- {String} tmxFile
- resourcePath
- Returns:
- {Boolean}
- Parameters:
- {Number} GID
- Returns:
- {object}
- Parameters:
- {Number} Var
- Parameters:
- {cc.Size} Var
- Parameters:
- {Array} Var
- Parameters:
- {object} Var
- Parameters:
- {cc.Size} Var