Class R.resources.types.Tile
Extends
R.resources.types.Sprite.
Represents a 2d tile. The difference between a sprite and a tile is that
tiles contain a "solidity map" which allows for raycasting when testing for collisions.
Otherwise, tiles and sprites are identical.
Defined in: tile.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.resources.types.Tile(name, tileObj, tileResource)
A tile is a sprite with the addition of a solidity map, computed from the
pixels of the sprite.
|
Field Attributes | Field Name and Description |
---|---|
All pixels are mixed, either transparent or opaque.
|
|
All pixels are opaque to collisions.
|
|
All pixels are transparent to collisions.
|
- Fields borrowed from class R.resources.types.Sprite:
- MODE_LOOP, MODE_ONCE, MODE_TOGGLE, TYPE_ANIMATION, TYPE_SINGLE
Method Attributes | Method Name and Description |
---|---|
clone(tile)
Specialized method to allow tiles to be cloned from one another.
|
|
destroy()
Destroy the sprite instance
|
|
Gets the class name of this object.
|
|
Get the sprite loader this sprite originated from
|
|
Get the resource this sprite originated from
|
|
Returns a flag indicating if the tile has been rendered to the context.
|
|
Mark the tile as having been rendered to the context.
|
|
release()
Release the sprite back into the pool for reuse
|
|
setRenderContext(renderContext)
Set the render context the tile is being rendered onto.
|
|
setSolidityMap(frame, solidityMap, statusFlag)
Set the solidity map for the tile, used during raycasts.
|
|
testPoint(point, time, dt)
Test if the given point, local to the tile's coordinates, would
result in a collision.
|
- Methods borrowed from class R.resources.types.Sprite:
- getBoundingBox, getFrame, getFrameCount, getFrameSpeed, getSourceImage, getSpeed, getSpriteLoader, getSpriteResource, gotoFrame, isAnimation, isLoop, isOnce, isToggle, play, reset, setSpeed, stop
- 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.types.Tile(name, tileObj, tileResource)
A tile is a sprite with the addition of a solidity map, computed from the
pixels of the sprite.
- Parameters:
- name
- {String} The name of the tile within the resource
- tileObj
- {Object} Passed in by a R.resources.loaders.TileLoader. An array which defines the tile frame, and parameters.
- tileResource
- {Object} The tile resource loaded by the R.resources.loaders.TileLoader
Field Detail
ALL_MIXED
All pixels are mixed, either transparent or opaque. Must perform
full ray testing on the solidity map.
ALL_OPAQUE
All pixels are opaque to collisions. Short-circuit test for ray casting.
ALL_TRANSPARENT
All pixels are transparent to collisions. Short-circuit test for ray casting.
Method Detail
clone(tile)
Specialized method to allow tiles to be cloned from one another. This method is also
called by R#clone when cloning objects.
- Parameters:
- tile
- {R.resources.types.Tile} Tile to clone from
destroy()
Destroy the sprite instance
{String}
getClassName()
Gets the class name of this object.
- Returns:
- {String} The string "R.resources.types.Tile"
{R.resources.loaders.SpriteLoader}
getTileLoader()
Get the sprite loader this sprite originated from
- Returns:
- {R.resources.loaders.SpriteLoader}
{Object}
getTileResource()
Get the resource this sprite originated from
- Returns:
- {Object}
{Boolean}
hasRendered()
Returns a flag indicating if the tile has been rendered to the context.
- Returns:
- {Boolean}
markRendered()
Mark the tile as having been rendered to the context. This is used for
HTML contexts where the tile should only render once unless it's an animated tile.
release()
Release the sprite back into the pool for reuse
setRenderContext(renderContext)
Set the render context the tile is being rendered onto. This allows tiles to
be rendered properly on HTML contexts.
- Parameters:
- renderContext
- {R.rendercontexts.AbstractRenderContext} The render context
setSolidityMap(frame, solidityMap, statusFlag)
Set the solidity map for the tile, used during raycasts. The status
flag is used to indicate if the pixels of the map need to be tested.
A solidity map will be computed for each frame of the tile, if the tile
is animated.
- Parameters:
- frame
- {Number} The frame number
- solidityMap
- {Array} An array of bits which indicate if a pixel is opaque or transparent
- statusFlag
- {Number} Flag used to assist in short-circuit testing
testPoint(point, time, dt)
Test if the given point, local to the tile's coordinates, would
result in a collision.
- Parameters:
- point
- {R.math.Point2D}
- time
- {Number} The current world time
- dt
- {Number} The delta between the world time and the last time the world was updated in milliseconds.