Crafty.sprite
public this Crafty.sprite([Number tile], String url, Object map[, Number paddingX[, Number paddingY]])
- tile
- Tile size of the sprite map, defaults to 1
- url
- URL of the sprite image
- map
- Object where the key is what becomes a new component and the value points to a position on the sprite map
- paddingX
- Horizontal space in between tiles. Defaults to 0.
- paddingY
- Vertical space in between tiles. Defaults to paddingX.
Generates components based on positions in a sprite image to be applied to entities.
Accepts a tile size, URL and map for the name of the sprite and it's position.
The position must be an array containing the position of the sprite where index 0
is the x position, 1 is the y position and optionally 2 is the width and 3
is the height. If the sprite map has padding, pass the values for the x padding
or y padding. If they are the same, just add one value.
If the sprite image has no consistent tile size, 1 or no argument need be
passed for tile size.
Entities that add the generated components are also given a component called Sprite.

@craftyjs
#crafty@freenode.net
google groups
louis@craftyjs.com
github