Package | laya.map |
Class | public class TiledMap |
Inheritance | TiledMap Object |
Property | Defined By | ||
---|---|---|---|
antiCrack : Boolean = true
是否调整地块边缘消除缩放导致的缝隙
| TiledMap | ||
autoCache : Boolean = true
是否自动缓存没有动画的地块
| TiledMap | ||
autoCacheType : String = normal
自动缓存类型,地图较大时建议使用normal
| TiledMap | ||
cacheAllAfterInit : Boolean = false
是否在加载完成之后cache所有大格子
| TiledMap | ||
enableMergeLayer : Boolean = false
是否合并图层,开启合并图层时,图层属性内可添加layer属性,运行时将会将相邻的layer属性相同的图层进行合并以提高性能
| TiledMap | ||
gridHeight : Number [read-only]
块的高度
| TiledMap | ||
gridWidth : Number [read-only]
块的宽度
| TiledMap | ||
height : int [read-only]
地图的高度
| TiledMap | ||
numColumnsGrid : Number [read-only]
地图的横向块数
| TiledMap | ||
numColumnsTile : int [read-only]
地图横向的格子数
| TiledMap | ||
numRowsGrid : int [read-only]
地图的坚向块数
| TiledMap | ||
numRowsTile : int [read-only]
地图竖向的格子数
| TiledMap | ||
orientation : String [read-only]
当前地图类型
| TiledMap | ||
removeCoveredTile : Boolean = false
是否移除被覆盖的格子,地块可添加type属性,type不为0时表示不透明,被不透明地块遮挡的地块将会被剔除以提高性能
| TiledMap | ||
renderOrder : String [read-only]
tile渲染顺序
| TiledMap | ||
scale : Number
得到当前地图的缩放
| TiledMap | ||
showGridTextureCount : Boolean = false
是否显示大格子里显示的贴图数量
| TiledMap | ||
tileHeight : int [read-only]
格子的高度
| TiledMap | ||
tileWidth : int [read-only]
格子的宽度
| TiledMap | ||
width : int [read-only]
地图的宽度
| TiledMap | ||
x : Number [read-only]
地图的x坐标
| TiledMap | ||
y : Number [read-only]
地图的y坐标
| TiledMap |
Method | Defined By | ||
---|---|---|---|
TiledMap() | TiledMap | ||
changeViewPort(moveX:Number, moveY:Number, width:Number, height:Number):void
改变视口大小
| TiledMap | ||
在锚点的基础上计算,通过宽和高,重新计算视口
| TiledMap | ||
createMap(mapName:String, viewRect:Rectangle, completeHandler:Handler, viewRectPadding:Rectangle = null, gridSize:Point = null, enableLinear:Boolean = true, limitRange:Boolean = false):void
创建地图
| TiledMap | ||
destroy():void
销毁地图
| TiledMap | ||
getLayerByIndex(index:int):MapLayer
通过索引得MapLayer
| TiledMap | ||
getLayerByName(layerName:String):MapLayer
得到指定的MapLayer
| TiledMap | ||
getLayerObject(layerName:String, objectName:String):GridSprite
得到对象层上的某一个物品
| TiledMap | ||
getMapProperties(name:String):*
得到地图的自定义属性
| TiledMap | ||
getSprite(index:int, width:Number, height:Number):GridSprite
通过纹理索引,生成一个可控制物件
| TiledMap | ||
getTexture(index:int):TileTexSet
得到一块指定的地图纹理
| TiledMap | ||
getTileProperties(index:int, id:int, name:String):*
得到tile自定义属性
| TiledMap | ||
getTileUserData(id:int, sign:String, defaultV:* = null):* | TiledMap | ||
整个地图的显示容器
| TiledMap | ||
moveViewPort(moveX:Number, moveY:Number):void
移动视口
| TiledMap | ||
setViewPortPivotByScale(scaleX:Number, scaleY:Number):void
设置视口的缩放中心点(例如:scaleX= scaleY= 0.5,就是以视口中心缩放)
| TiledMap |
Constant | Defined By | ||
---|---|---|---|
ORIENTATION_HEXAGONAL : String = hexagonal [static] 六边形地图 | TiledMap | ||
ORIENTATION_ISOMETRIC : String = isometric [static] 菱形地图 | TiledMap | ||
ORIENTATION_ORTHOGONAL : String = orthogonal [static] 四边形地图 | TiledMap | ||
ORIENTATION_STAGGERED : String = staggered [static] 45度交错地图 | TiledMap | ||
RENDERORDER_LEFTDOWN : String = left-down [static] 地图格子从右上角开始渲染 | TiledMap | ||
RENDERORDER_LEFTUP : String = left-up [static] 地图格子右下角开始渲染 | TiledMap | ||
RENDERORDER_RIGHTDOWN : String = right-down [static] 地图格子从左上角开始渲染 | TiledMap | ||
RENDERORDER_RIGHTUP : String = right-up [static] 地图格子从左下角开始渲染 | TiledMap |
antiCrack | property |
public var antiCrack:Boolean = true
是否调整地块边缘消除缩放导致的缝隙
autoCache | property |
public var autoCache:Boolean = true
是否自动缓存没有动画的地块
autoCacheType | property |
public var autoCacheType:String = normal
自动缓存类型,地图较大时建议使用normal
cacheAllAfterInit | property |
public var cacheAllAfterInit:Boolean = false
是否在加载完成之后cache所有大格子
enableMergeLayer | property |
public var enableMergeLayer:Boolean = false
是否合并图层,开启合并图层时,图层属性内可添加layer属性,运行时将会将相邻的layer属性相同的图层进行合并以提高性能
gridHeight | property |
gridHeight:Number
[read-only] 块的高度
public function get gridHeight():Number
gridWidth | property |
gridWidth:Number
[read-only] 块的宽度
public function get gridWidth():Number
height | property |
height:int
[read-only] 地图的高度
public function get height():int
numColumnsGrid | property |
numColumnsGrid:Number
[read-only] 地图的横向块数
public function get numColumnsGrid():Number
numColumnsTile | property |
numColumnsTile:int
[read-only] 地图横向的格子数
public function get numColumnsTile():int
numRowsGrid | property |
numRowsGrid:int
[read-only] 地图的坚向块数
public function get numRowsGrid():int
numRowsTile | property |
numRowsTile:int
[read-only] 地图竖向的格子数
public function get numRowsTile():int
orientation | property |
orientation:String
[read-only] 当前地图类型
public function get orientation():String
removeCoveredTile | property |
public var removeCoveredTile:Boolean = false
是否移除被覆盖的格子,地块可添加type属性,type不为0时表示不透明,被不透明地块遮挡的地块将会被剔除以提高性能
renderOrder | property |
renderOrder:String
[read-only] tile渲染顺序
public function get renderOrder():String
scale | property |
scale:Number
得到当前地图的缩放
public function get scale():Number
public function set scale(value:Number):void
showGridTextureCount | property |
public var showGridTextureCount:Boolean = false
是否显示大格子里显示的贴图数量
tileHeight | property |
tileHeight:int
[read-only] 格子的高度
public function get tileHeight():int
tileWidth | property |
tileWidth:int
[read-only] 格子的宽度
public function get tileWidth():int
width | property |
width:int
[read-only] 地图的宽度
public function get width():int
x | property |
x:Number
[read-only] 地图的x坐标
public function get x():Number
y | property |
y:Number
[read-only] 地图的y坐标
public function get y():Number
TiledMap | () | Constructor |
public function TiledMap()
changeViewPort | () | method |
public function changeViewPort(moveX:Number, moveY:Number, width:Number, height:Number):void
改变视口大小
Parameters
moveX:Number — 视口的坐标x
| |
moveY:Number — 视口的坐标y
| |
width:Number — 视口的宽
| |
height:Number — 视口的高
|
changeViewPortBySize | () | method |
public function changeViewPortBySize(width:Number, height:Number, rect:Rectangle = null):Rectangle
在锚点的基础上计算,通过宽和高,重新计算视口
Parameters
width:Number — 新视口宽
| |
height:Number — 新视口高
| |
rect:Rectangle (default = null ) — 返回的结果
|
Rectangle —
|
createMap | () | method |
public function createMap(mapName:String, viewRect:Rectangle, completeHandler:Handler, viewRectPadding:Rectangle = null, gridSize:Point = null, enableLinear:Boolean = true, limitRange:Boolean = false):void
创建地图
Parameters
mapName:String — JSON文件名字
| |
viewRect:Rectangle — 视口区域
| |
completeHandler:Handler — 地图创建完成的回调函数
| |
viewRectPadding:Rectangle (default = null ) — 视口扩充区域,把视口区域上、下、左、右扩充一下,防止视口移动时的穿帮
| |
gridSize:Point (default = null ) — grid大小
| |
enableLinear:Boolean (default = true ) — 是否开启线性取样(为false时,可以解决地图黑线的问题,但画质会锐化)
| |
limitRange:Boolean (default = false ) — 把地图限制在显示区域
|
destroy | () | method |
public function destroy():void
销毁地图
getLayerByIndex | () | method |
public function getLayerByIndex(index:int):MapLayer
通过索引得MapLayer
Parameters
index:int — 要找的层索引
|
MapLayer —
|
getLayerByName | () | method |
public function getLayerByName(layerName:String):MapLayer
得到指定的MapLayer
Parameters
layerName:String — 要找的层名称
|
MapLayer —
|
getLayerObject | () | method |
public function getLayerObject(layerName:String, objectName:String):GridSprite
得到对象层上的某一个物品
Parameters
layerName:String — 层的名称
| |
objectName:String — 所找物品的名称
|
GridSprite —
|
getMapProperties | () | method |
public function getMapProperties(name:String):*
得到地图的自定义属性
Parameters
name:String — 属性名称
|
* —
|
getSprite | () | method |
public function getSprite(index:int, width:Number, height:Number):GridSprite
通过纹理索引,生成一个可控制物件
Parameters
index:int — 纹理的索引值,默认从1开始
| |
width:Number | |
height:Number |
GridSprite —
|
getTexture | () | method |
public function getTexture(index:int):TileTexSet
得到一块指定的地图纹理
Parameters
index:int — 纹理的索引值,默认从1开始
|
TileTexSet —
|
getTileProperties | () | method |
public function getTileProperties(index:int, id:int, name:String):*
得到tile自定义属性
Parameters
index:int — 地图块索引
| |
id:int — 具体的TileSetID
| |
name:String — 属性名称
|
* —
|
getTileUserData | () | method |
public function getTileUserData(id:int, sign:String, defaultV:* = null):*
Parameters
id:int | |
sign:String | |
defaultV:* (default = null )
|
* |
mapSprite | () | method |
moveViewPort | () | method |
public function moveViewPort(moveX:Number, moveY:Number):void
移动视口
Parameters
moveX:Number — 视口的坐标x
| |
moveY:Number — 视口的坐标y
|
setViewPortPivotByScale | () | method |
public function setViewPortPivotByScale(scaleX:Number, scaleY:Number):void
设置视口的缩放中心点(例如:scaleX= scaleY= 0.5,就是以视口中心缩放)
Parameters
scaleX:Number | |
scaleY:Number |
ORIENTATION_HEXAGONAL | Constant |
public static const ORIENTATION_HEXAGONAL:String = hexagonal
六边形地图
ORIENTATION_ISOMETRIC | Constant |
public static const ORIENTATION_ISOMETRIC:String = isometric
菱形地图
ORIENTATION_ORTHOGONAL | Constant |
public static const ORIENTATION_ORTHOGONAL:String = orthogonal
四边形地图
ORIENTATION_STAGGERED | Constant |
public static const ORIENTATION_STAGGERED:String = staggered
45度交错地图
RENDERORDER_LEFTDOWN | Constant |
public static const RENDERORDER_LEFTDOWN:String = left-down
地图格子从右上角开始渲染
RENDERORDER_LEFTUP | Constant |
public static const RENDERORDER_LEFTUP:String = left-up
地图格子右下角开始渲染
RENDERORDER_RIGHTDOWN | Constant |
public static const RENDERORDER_RIGHTDOWN:String = right-down
地图格子从左上角开始渲染
RENDERORDER_RIGHTUP | Constant |
public static const RENDERORDER_RIGHTUP:String = right-up
地图格子从左下角开始渲染