Phaser. Tileset

new Tileset(name, firstgid, width, height, margin, spacing, properties)

A Tile set is a combination of an image containing the tiles and collision data per tile.

Tilesets are normally created automatically when Tiled data is loaded.

Parameters:
Name Type Argument Default Description
name string

The name of the tileset in the map data.

firstgid integer

The first tile index this tileset contains.

width integer <optional>
32

Width of each tile (in pixels).

height integer <optional>
32

Height of each tile (in pixels).

margin integer <optional>
0

The margin around all tiles in the sheet (in pixels).

spacing integer <optional>
0

The spacing between each tile in the sheet (in pixels).

properties object <optional>
{}

Custom Tileset properties.

Source - tilemap/Tileset.js, line 22

Members

<readonly> columns :integer

The number of tile columns in the tileset.

Source - tilemap/Tileset.js, line 101

firstgid :integer

The Tiled firstgid value. This is the starting index of the first tile index this Tileset contains.

Source - tilemap/Tileset.js, line 40

<readonly> image :object

The cached image that contains the individual tiles. Use setImage to set.

Source - tilemap/Tileset.js, line 85

name :string

The name of the Tileset.

Source - tilemap/Tileset.js, line 33

properties :object

Tileset-specific properties that are typically defined in the Tiled editor.

Source - tilemap/Tileset.js, line 77

<readonly> rows

The number of tile rows in the the tileset.

Properties:
Type Description
integer
Source - tilemap/Tileset.js, line 93

<readonly> tileHeight :integer

The height of each tile (in pixels).

Source - tilemap/Tileset.js, line 54

<readonly> tileMargin

The margin around the tiles in the sheet (in pixels). Use setSpacing to change.

Properties:
Name Type Description
tileMarge integer
Source - tilemap/Tileset.js, line 63

<readonly> tileSpacing :integer

The spacing between each tile in the sheet (in pixels). Use setSpacing to change.

Source - tilemap/Tileset.js, line 71

<readonly> tileWidth :integer

The width of each tile (in pixels).

Source - tilemap/Tileset.js, line 47

<readonly> total :integer

The total number of tiles in the tileset.

Source - tilemap/Tileset.js, line 109

Methods

containsTileIndex() → {boolean}

Returns true if and only if this tileset contains the given tile index.

Returns:
boolean -

True if this tileset contains the given index.

Source - tilemap/Tileset.js, line 155

draw(context, x, y, index)

Draws a tile from this Tileset at the given coordinates on the context.

Parameters:
Name Type Description
context CanvasRenderingContext2D

The context to draw the tile onto.

x number

The x coordinate to draw to.

y number

The y coordinate to draw to.

index integer

The index of the tile within the set to draw.

Source - tilemap/Tileset.js, line 123

setImage(image)

Set the image associated with this Tileset and update the tile data.

Parameters:
Name Type Description
image Image

The image that contains the tiles.

Source - tilemap/Tileset.js, line 171

setSpacing(margin, spacing)

Sets tile spacing and margins.

Parameters:
Name Type Argument Default Description
margin integer <optional>
0

The margin around the tiles in the sheet (in pixels).

spacing integer <optional>
0

The spacing between the tiles in the sheet (in pixels).

Source - tilemap/Tileset.js, line 185
Phaser Copyright © 2012-2015 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.2 on Thu Feb 18 2016 14:41:08 GMT+0000 (GMT Standard Time) using the DocStrap template.

快捷菜单

注意:只有登录才能全文翻译,每个新用户赠送300会员币。
赚取方法:文章评论+1000,分享网站截图给站长+3000,另充10元+100万会员币
支持一下记得截图给站长!

VIP限时免费阅读!登录可得1万币尽情中文阅读!


记得CTRL+D收藏!
站长微信:
支持自学php网
如有问题,记得强刷一下.

  • columns :integer - 属性
  • firstgid :integer - 属性
  • image :object - 属性
  • name :string - 属性
  • properties :object - 属性
  • rows - 方法
  • tileHeight :integer - 属性
  • tileMargin - 方法
  • tileSpacing :integer - 属性
  • tileWidth :integer - 属性
  • total :integer - 属性
  • containsTileIndex() → {boolean} - 方法
  • draw(context, x, y, index) - 方法
  • setImage(image) - 方法
  • setSpacing(margin, spacing) - 方法