News | About | Download | Documentation | Development | Links

Sprites Resources

Resource options

The sprite resource options is a plethora of possibilites to tweak a sprites looks and behaviours, but all of them have default values. In most cases you will only need to use the basic options.

TODO: The frame cutter approach. Explain the 4 different cutters.

Each sprite CAN have the following properties:

my_sprite =
(
	type = sprite,

	imageX = filename,
	imageX_method = [single, grid, palette, alpha],

	// Options only if imageX_method is 'grid':
	imageX_pos = (x, y),
	imageX_size = (width, height),
	imageX_array = (width, height),
	imageX_array_skipframes = integer,
	imageX_spacing = (x, y),
	imageX_tcol = (col1, col2, col3 ... colX),

	// Options only if imageX_method is 'palette':
	imageX_pos = (x, y),

	// Options only if imageX_method is 'alpha':
	imageX_pos = (x, y),
	imageX_trans_limit = float,

	play_options = ([pingpong, nopingpong], [loop, noloop], [backward, forward]),
	play_speed = integer,
	show_on_finish = [blank, last_frame, first_frame],

	base_angle = float,

	rotation_hotspot = (
		[top_left, top_center, top_right, center_left, center, center_right, bottom_left, bottom_center, bottom_right],
		x-offset, y-offset),
	translation_hotspot = (
		[top_left, top_center, top_right, center_left, center, center_right, bottom_left, bottom_center, bottom_right],
		x-offset, y-offset),

	scale = (float, float),

	color = (float, float, float, float),
	alpha = float,

	frameX_speed = integer,
	frameX_offset = (x-offset, y-offset),
);

All properties are optional, except the imageX values and the type = sprite. Omitted properties will get a default value.

Examples

Some examples:

my_simple_sprite =
(
	type = sprite,

	image1 = image_single1.tga,
	image2 = image_single2.tga,
	image3 = image_single3.tga,	
};

my_advanced_sprite =
(
	type = sprite,

	image1 = image1.tga,

	image2 = gridframes.tga,	
	image2_method = grid,
	image2_array = (10, 2),
	image2_size = (32, 32),

	image3 = alphaframes.tga,
	image3_method = alpha

	image4 = image2.tga,

	image5 = image3.tga,
	image5_method = grid,
	image5_size = (32, 32),

	alpha = 0.5,
	
	base_angle = 90,

	frame20_offset = (1, 1),
	frame20_speed = 100
};

As you can see, you can interchange any cutmethod in a sprite, it just adds the frames sequentially. This sprite consists of 1+20+?+1+1 frames (the ? depends on how many frames there were in the alphaframes.tga).

Since most options have a default value, you can safely remove those unless you want another value. I.e. in my_advanced_sprite/image1, we have omitted the image1_method = single, in image2 we omitted image2_pos = (0,0), in image5 we omitted image5_array = (1,1). Using the gridcutter to cut only one frame makes it possible to use a subsection of a surface.



Questions or comments, write to the ClanLib mailing list.