CollageSpriteSheet - coldrockgames/gml-raptor GitHub Wiki
This class defines a sprite sheet with a builder pattern, that lets you freely add sprites to your collage.
The sheet may be organized in any way, horizontal or vertical, each animation sequence may run over several rows or columns and start anywhere on the sheet.
- A sprite sheet must be contained in one single
.png
file. Multi-file sheets are not supported. - All sprites on one sheet must have the same frame size and origins.
- Sprites may have different sequence lengths and different animation speeds (fps).
- You can only set the entire sheet to be on a separate Texture Page, not a single sprite in it.
- You may set the line mode (see below) only for the entire sheet, not per sprite.
By calling .add_spritesheet
on the CollageManager
, you start a new method chain, the builder for the sprite sheet. You stay in this chain, until you finalize it by calling .build()
(as you do with almost any builder pattern).
/// @func add_sprite(_name, _frame_count, _fps = 0)
/// @desc Add a sprite with its frame_count and fps
static add_sprite = function(_name, _frame_count, _fps = 0, _tolerance = 0) {
/// @func set_start_position(_sheet_start_x = 0, _sheet_start_y = 0)
/// @desc Define the x/y position of the first frame in the sheet
static set_start_position = function(_sheet_start_x = 0, _sheet_start_y = 0) {
/// @func set_frame_size(_frame_width = 0, _frame_height = 0)
/// @desc Set the frame size for the sprites of this sheet
static set_frame_size = function(_frame_width = 0, _frame_height = 0) {
/// @func set_origins(_xorigin = 0, _yorigin = 0)
/// @desc Set the origins of the sprites in this sheet
static set_origins = function(_xorigin = 0, _yorigin = 0) {
/// @func set_alignment(_horizontal_alignment = true)
/// @desc Set the sheet alignment horizontal or vertical
static set_alignment = function(_horizontal_alignment = true) {
/// @func set_remove_back(_remove_back = false)
/// @desc Set whether to remove the background color of the sheet
static set_remove_back = function(_remove_back = false) {
/// @func set_smooth(_smooth = false)
/// @desc Set whether GameMaker shall use anti-aliasing when
/// when removing the background color
static set_smooth = function(_smooth = false) {
/// @func set_separate_texture(_separate_texture)
/// @desc Set to true to assign an exclusive texture page
/// for this sprite sheet
static set_separate_texture = function(_separate_texture) {
/// @func set_line_mode_zero()
/// @desc Sets whether the spritesheet starts
/// the next line at position 0 (default)
static set_line_mode_zero = function() {
/// @func set_line_mode_rectangle()
/// @desc Sets whether the SpriteSheet starts
/// the next line at the start position
static set_line_mode_rectangle = function() {
Similar to the entire collage, you finish your builder chain with this method. It takes care about async process waiting and will do its calculations, as soon as all images have arrived.
/// @func build()
/// @desc Build the sprite sheet now and create the sheet defs
static build = function() {
Take a look at the full example at Collage Builder Example.