Class Index | File Index

Classes


Class cc.TMXLayer


Extends cc.SpriteBatchNode.

Defined in: CCTMXLayer.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

cc.TMXLayer represents the TMX layer.

Method Summary
Method Attributes Method Name and Description
 
addChild(child)
cc.TMXLayer doesn't support adding a cc.Sprite manually.
<static>  
cc.TMXLayer.create(tilesetInfo, layerInfo, mapInfo)
Creates a cc.TMXLayer with an tile set info, a layer info and a map info
 
ctor()
Constructor
 
 
Layer orientation, which is the same as the map orientation
 
 
Size of the map's tile (could be different from the tile's size)
 
Returns the position in pixels of a given tile coordinate
 
properties from the layer.
 
getProperty(propertyName)
Return the value for the specific property name
 
getTileAt(pos)

Returns the tile (cc.Sprite) at a given a tile coordinate.

 
lipped tiles can be changed dynamically
 
Returns the tile gid at a given tile coordinate.
 
Pointer to the map of tiles
 
Tile set information for the layer
 
initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo)
Initializes a cc.TMXLayer with a tileset info, a layer info and a map info
 

Dealloc the map that contains the tile position from memory.

 
removeChild(child, cleanup)
Remove child
 
Removes a tile at given tile coordinate
 
setLayerName(layerName)
 
 
 
 
 
setTileGID(gid, pos, flags)

Sets the tile gid (gid = tile global id) at a given tile coordinate.

 
setTiles(Var)
 
 
Creates the tiles
Methods borrowed from class cc.SpriteBatchNode:
addQuadFromSprite, addSpriteWithoutQuad, appendChild, atlasIndexForChild, draw, getBlendFunc, getDescendants, getTexture, getTextureAtlas, highestAtlasIndexInChild, increaseAtlasCapacity, init, initWithTexture, insertChild, lowestAtlasIndexInChild, rebuildIndexInOrder, removeAllChildren, removeChildAtIndex, removeSpriteFromAtlas, reorderBatch, reorderChild, setBlendFunc, setContentSize, setNodeDirty, setTexture, setTextureAtlas, sortAllChildren, visit
Methods borrowed from class cc.Node:
cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, description, 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, isIgnoreAnchorPointForPosition, isRunning, isVisible, nodeToParentTransform, nodeToWorldTransform, numberOfRunningActions, onEnter, onEnterTransitionDidFinish, onExit, onExitTransitionDidStart, parentToNodeTransform, pauseSchedulerAndActions, release, removeAllChildrenWithCleanup, removeChildByTag, removeFromParent, removeFromParentAndCleanup, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setGLServerState, setGrid, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setRotation, setScale, setScaleX, setScaleY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, update, updateTransform, worldToNodeTransform
Class Detail
cc.TMXLayer()

cc.TMXLayer represents the TMX layer.

It is a subclass of cc.SpriteBatchNode. By default the tiles are rendered using a cc.TextureAtlas.
If you modify a tile on runtime, then, that tile will become a cc.Sprite, otherwise no cc.Sprite objects are created.
The benefits of using cc.Sprite objects as tiles are:
- tiles (cc.Sprite) can be rotated/scaled/moved with a nice API

If the layer contains a property named "cc.vertexz" with an integer (in can be positive or negative),
then all the tiles belonging to the layer will use that value as their OpenGL vertex Z for depth.

On the other hand, if the "cc.vertexz" property has the "automatic" value, then the tiles will use an automatic vertex Z value.
Also before drawing the tiles, GL_ALPHA_TEST will be enabled, and disabled after drawing them. The used alpha func will be:

glAlphaFunc( GL_GREATER, value )

"value" by default is 0, but you can change it from Tiled by adding the "cc_alpha_func" property to the layer.
The value 0 should work for most cases, but if you have tiles that are semi-transparent, then you might want to use a different value, like 0.5.

Method Detail
addChild(child)
cc.TMXLayer doesn't support adding a cc.Sprite manually.
Parameters:
{cc.Node} child

<static> {cc.TMXLayer|Null} cc.TMXLayer.create(tilesetInfo, layerInfo, mapInfo)
Creates a cc.TMXLayer with an tile set info, a layer info and a map info
Parameters:
{cc.TMXTilesetInfo} tilesetInfo
{cc.TMXLayerInfo} layerInfo
{cc.TMXMapInfo} mapInfo
Returns:
{cc.TMXLayer|Null}

ctor()
Constructor

{String} getLayerName()
Returns:
{String}

{Number} getLayerOrientation()
Layer orientation, which is the same as the map orientation
Returns:
{Number}

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

{cc.Size} getMapTileSize()
Size of the map's tile (could be different from the tile's size)
Returns:
{cc.Size}

{cc.Point} getPositionAt(pos)
Returns the position in pixels of a given tile coordinate
Parameters:
{cc.Point} pos
Returns:
{cc.Point}

{Array} getProperties()
properties from the layer. They can be added using Tiled
Returns:
{Array}

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

{cc.Sprite} getTileAt(pos)

Returns the tile (cc.Sprite) at a given a tile coordinate.
The returned cc.Sprite will be already added to the cc.TMXLayer. Don't add it again.
The cc.Sprite can be treated like any other cc.Sprite: rotated, scaled, translated, opacity, color, etc.
You can remove either by calling:
- layer.removeChild(sprite, cleanup);
- or layer.removeTileAt(ccp(x,y));

Parameters:
{cc.Point} pos
Returns:
{cc.Sprite}

{Number} getTileFlagsAt(pos)
lipped tiles can be changed dynamically
Parameters:
{cc.Point} pos
Returns:
{Number}

{Number} getTileGIDAt(pos)
Returns the tile gid at a given tile coordinate.
if it returns 0, it means that the tile is empty.
This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
Parameters:
{cc.Point} pos
Returns:
{Number}

{Array} getTiles()
Pointer to the map of tiles
Returns:
{Array}

{cc.TMXTilesetInfo} getTileSet()
Tile set information for the layer
Returns:
{cc.TMXTilesetInfo}

{Boolean} initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo)
Initializes a cc.TMXLayer with a tileset info, a layer info and a map info
Parameters:
{cc.TMXTilesetInfo} tilesetInfo
{cc.TMXLayerInfo} layerInfo
{cc.TMXMapInfo} mapInfo
Returns:
{Boolean}

releaseMap()

Dealloc the map that contains the tile position from memory.
Unless you want to know at runtime the tiles positions, you can safely call this method.
If you are going to call layer.getTileGIDAt() then, don't release the map


removeChild(child, cleanup)
Remove child
Parameters:
{cc.Node} child
{Boolean} cleanup

removeTileAt(pos)
Removes a tile at given tile coordinate
Parameters:
{cc.Point} pos

setLayerName(layerName)
Parameters:
{String} layerName

setLayerOrientation(Var)
Parameters:
{Number} Var

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

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

setProperties(Var)
Parameters:
{Array} Var

setTileGID(gid, pos, flags)

Sets the tile gid (gid = tile global id) at a given tile coordinate.
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
If a tile is already placed at that position, then it will be removed.

Parameters:
{Number} gid
{cc.Point} pos
{Number} flags

setTiles(Var)
Parameters:
{Array} Var

setTileSet(Var)
Parameters:
{cc.TMXTilesetInfo} Var

setupTiles()
Creates the tiles

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