Difference between revisions of "NML:Realsprites"

From GRFSpecs
Jump to navigationJump to search
(When there's only one flag, there's nothing to combine with OR)
(Templates are part of realsprites as they can only be used there)
Line 1: Line 1:
 
{{NMLNavBlocksyntax}}
 
{{NMLNavBlocksyntax}}
  +
  +
== Real sprites ==
   
 
Several features will need to reference actual graphics from files you created. You can provide real sprites in many different formats, all detailed below. There is a lot of information you'll need to provide. Most important are the filename and the location of the sprite in that file. Since most blocks that reference realsprites will allow you to specify a default filename, you don't often need to give a filename for every separate sprite.
 
Several features will need to reference actual graphics from files you created. You can provide real sprites in many different formats, all detailed below. There is a lot of information you'll need to provide. Most important are the filename and the location of the sprite in that file. Since most blocks that reference realsprites will allow you to specify a default filename, you don't often need to give a filename for every separate sprite.
Line 34: Line 36:
 
[0, 0, 64, 31, -31, 0, TILE]
 
[0, 0, 64, 31, -31, 0, TILE]
 
</pre>
 
</pre>
  +
  +
  +
== Templates ==
  +
  +
NML allows to define templates to avoid repetitive declaration of the same sprite alignment (e.g. when coding different train wagons of the same size). The may be used in any place where a real sprite would be used. Templates may also be nested. Parameters may be numbers or strings (for the filename).
  +
  +
  +
template templatename([param [, param [, param...]]]) {
  +
[[NML:Realsprites|list of realsprites]]
  +
...
  +
}
  +
  +
For an example see the [[NML:Spritegroup|spritegroup]].

Revision as of 00:22, 9 September 2011

Block Syntax

Real sprites

Several features will need to reference actual graphics from files you created. You can provide real sprites in many different formats, all detailed below. There is a lot of information you'll need to provide. Most important are the filename and the location of the sprite in that file. Since most blocks that reference realsprites will allow you to specify a default filename, you don't often need to give a filename for every separate sprite.

Allowed formats:

[left_x, upper_y, width, height, offset_x, offset_y]
[left_x, upper_y, width, height, offset_x, offset_y, compression]
[left_x, upper_y, width, height, offset_x, offset_y, filename]
[left_x, upper_y, width, height, offset_x, offset_y, compression, filename]
[offset_x, offset_y]
[offset_x, offset_y, compression]
[offset_x, offset_y, filename]
[offset_x, offset_y, compression, filename]

If you don't specify left_x, upper_y, width and height it'll default to the complete file. If you don't specify the filename it'll take the filename from the block containing this realsprite. It's a fatal error not to specify a filename for either the block containing a realsprite or the realsprite itself. For possible values of compression, see the table below.

For all parameters you can use expressions as complex as you want as long as they can be resolved at compile time.

As of NML r1654 the compression bit has only two possible values. When ommitted it will take the default value.

Name Description
CROP (default) or NOCROP Whether to crop the sprites when the -c command line option is set.


Example:

 [0, 0, 64, 31, -31, 0, TILE]


Templates

NML allows to define templates to avoid repetitive declaration of the same sprite alignment (e.g. when coding different train wagons of the same size). The may be used in any place where a real sprite would be used. Templates may also be nested. Parameters may be numbers or strings (for the filename).


template templatename([param [, param [, param...]]]) {
	list of realsprites
	...
}

For an example see the spritegroup.