public this Crafty.sprite([Number tile], String url, Object map[, Number paddingX[, Number paddingY]])
- Tile size of the sprite map, defaults to 1
- URL of the sprite image
- Object where the key is what becomes a new component and the value points to a position on the sprite map
- Horizontal space in between tiles. Defaults to 0.
- 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
1 is the
y position and optionally
2 is the width and
is the height. If the sprite map has padding, pass the values for the
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