Class R.resources.loaders.TileLoader
Extends
R.resources.loaders.SpriteLoader.
Loads tile resources and makes them available to the system. Tiles are
defined by an external JSON resource file. A tile definition file
is a JSON file which is nearly identical to sprite sheets. The format
describes the image which contains the sprites, the dimensions of the image,
the version of the file, and the tile definitions. Tiles can be either single
frames or animations. Animations are expected to be sequentially organized
in the bitmap from left to right. Each frame of an animation must be the exact
same dimensions.
{ // Tile definition file v2 "bitmapImage": "bitmapFile.ext", "bitmapSize": [320, 320], "version": 2 "sparsity": 1, "transparencyThreshold": 0, "assumeOpaque": false, "tiles": { "girder": [0, 0, 32, 32], "gears": [32, 0, 32, 32, 3, 150, "loop"] } }Note: The new file structure is a bit more compact, and is indicated with the "version" key in the file, set to the value 2. Version 1 will be deprecated and will not be supported in a future release of The Render Engine.
Defined in: tileloader.js.
Constructor Attributes | Constructor Name and Description |
---|---|
- Fields borrowed from class R.resources.loaders.ImageLoader:
- loadAdjust
- Fields borrowed from class R.resources.loaders.RemoteLoader:
- STATUS_CACHED, STATUS_NOT_FOUND, STATUS_OK, STATUS_SERVER_ERROR
Method Attributes | Method Name and Description |
---|---|
afterLoad(name, info)
Called after the data has been loaded, passing along the info object and name
of the sprite resource.
|
|
exportAll(resource, tileNames)
Export all of the tiles in the specified resource, as a JavaScript object, with the
tile name as the key and the corresponding R.resources.types.Tile as the value.
|
|
Get the class name of this object.
|
|
getOpacityFlag(resource)
Get the state of the flag indicating if all tiles should be considered fully opaque.
|
|
The name of the resource this loader will get.
|
|
getSparsity(resource)
Sparsity is used to reduce the size of the solidity map for each frame of every tile.
|
|
getThreshold(resource)
Get the transparency threshold at which pixels are considered to be either transparent or
solid.
|
|
getTile(resource, tile)
Creates a R.resources.types.Tile object representing the named tile.
|
- Methods borrowed from class R.resources.loaders.SpriteLoader:
- get, getSprite, getSpriteNames, isReady, load
- Methods borrowed from class R.resources.loaders.ImageLoader:
- getDimensions, getImage, getResourceObject, loadImageResource
- Methods borrowed from class R.resources.loaders.RemoteLoader:
- exists, getPathUrl, setPathUrl
- Methods borrowed from class R.resources.loaders.AbstractResourceLoader:
- clear, destroy, getCachedObjects, getResources, release, set, setReady, unload
- Methods borrowed from class R.engine.BaseObject:
- addEvent, addEvents, getElement, jQ, removeEvent, setElement, triggerEvent, update
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Class Detail
R.resources.loaders.TileLoader(name)
- Parameters:
- name
- {String=TileLoader} The name of the resource loader
Method Detail
afterLoad(name, info)
Called after the data has been loaded, passing along the info object and name
of the sprite resource.
- Parameters:
- name
- {String} The name of the sprite resource
- info
- {Object} The sprite resource definition
exportAll(resource, tileNames)
Export all of the tiles in the specified resource, as a JavaScript object, with the
tile name as the key and the corresponding R.resources.types.Tile as the value.
- Parameters:
- resource
- {String} The name of the tile resource
- tileNames Optional
- {Array} An optional array of tiles to export, by name,
or
null to export all tiles
{String}
getClassName()
Get the class name of this object.
- Returns:
- {String} The string "R.resources.loaders.TileLoader"
{Boolean}
getOpacityFlag(resource)
Get the state of the flag indicating if all tiles should be considered fully opaque.
- Parameters:
- resource
- {String} The name of the tile resource
- Returns:
- {Boolean}
{String}
getResourceType()
The name of the resource this loader will get.
- Returns:
- {String} The string "tile"
{Number}
getSparsity(resource)
Sparsity is used to reduce the size of the solidity map for each frame of every tile.
The higher the sparsity, the more pixels will be averaged together to get a smaller map.
This has the potential to improve performance when performing ray casting by eliminating
the need to calculate collisions per pixel.
- Parameters:
- resource
- {String} The name of the tile resource
- Returns:
- {Number}
{Number}
getThreshold(resource)
Get the transparency threshold at which pixels are considered to be either transparent or
solid. Pixel alpha values above the specified threshold will be considered solid when
calculating the solidity map of a tile.
- Parameters:
- resource
- {String} The name of the tile resource
- Returns:
- {Number} Value between 0 and 255
{R.resources.types.Tile}
getTile(resource, tile)
Creates a R.resources.types.Tile object representing the named tile.
- Parameters:
- resource
- {String} The name of a loaded tile resource
- tile
- {String} The name of the tile from the resource
- Returns:
- {R.resources.types.Tile} A R.resources.types.Tile instance