Sprite Sheet Importer

by DarkCampainger
[Share] [Zip]
To download this demo for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://DarkCampainger.SpriteSheetImporter##version=0

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://DarkCampainger.SpriteSheetImporter##version=0

383 downloads
Version 1.0 (Initial)
Date added: Aug 9 2012
12 fans
Quickly import sprite sheets into full movie icon_states using a simple markup [More]
/* ********************************************************* /
_____ _ __ _____ __ __
/ ___/____ _____(_) /____ / ___// /_ ___ ___ / /_
\__ \/ __ \/ ___/ / __/ _ \ \__ \/ __ \/ _ \/ _ \/ __/
___/ / /_/ / / / / /_/ __/ ___/ / / / / __/ __/ /_
/____/ .___/_/ /_/\__/\___/ /____/_/ /_/\___/\___/\__/
/_/
____ __
/ _/___ ___ ____ ____ _____/ /____ _____
/ // __ `__ \/ __ \/ __ \/ ___/ __/ _ \/ ___/
_/ // / / / / / /_/ / /_/ / / / /_/ __/ /
/___/_/ /_/ /_/ .___/\____/_/ \__/\___/_/
/_/
*/
//////////////////////////////////////////////////////////

Created by DarkCampainger
Version 1.0 / August 9, 2012

"' This tool allows you to import a spritesheet by defining
"' the sequence of states as they appear in the source image.
"'
"' The different directions and even frames for any individual
"' state do not need to be adjacent.
"'
"' The following can be defined:
"'
"' - Global icon width, height, spacing, margins, and scan order
"'
"' - Icon state name, movement flag, rewind flag, directions,
"' frames, and delays
"
"' You use the importer by writing a 'blueprint' script that lays
"' out the states.
"'
"' See 'skeleton.txt' and 'skeleton.png' for an example blueprint.
"'
"' Blueprints start with a header that defines the global params:
"'
// # Defines the width of each state
//
## Width: 32
//
// # Defines the height of each state
//
## Height: 32
//
// # Spacing defines the INTERNAL spacing between each state.
// # First number is the horizontal spacing, second is vertical.
// # Spacing is NOT applied around the outer edges of the
// # sprite sheet (hence it being "internal" spacing)
//
## Spacing: 0 0
//
// # Margin defines the external margins around the edges of the
// # sprite sheet. The margins can be specified individually
// # in this order: top, right, bottom, left.
//
## Margin: 0
//
// # Order defines how the the importer moves over the sprite sheet.
// # The first value is the primary direction, followed by the
// # secondary direction.
// # Valid values are ltr (left-to-right), rtl (right-to-left),
// # ttb (top-to-bottom), and btt (bottom-to-top).
//
## Order: ltr, ttb
//
//
"' After the header you define the strips of state data:
//
// # Here's all the options used at once:
//
## "StateName", Movement, Rewind, (S,N,E,W), 8, (1,4,2,1)
//
// # Each line must start with the state's name in quotes
// #
// # The following can optionally be defined (in this order):
// # Movement / M - Load strip as part of movement state
// # Rewind / R - Make state play in reverse
// # (S,N,E,W) - Directions in strip (S,N,E,W,NE,NW,SE,
// # and/or SW). You can leave off the parens
// # if its a single direction
// # 8 - Number of frames in the state
// # (1,4,2,1) - Delays for each frame (unspecified delays
// # default to the last set delay). You can
// # leave off the parens if its a single delay
// #
// # If you define the frame delays, you must specify the
// # number of frames
// #
// # Based on these strips, the importer moves from grid cell to
// # grid cell (based on the order in the header) pulling out
// # the required number of sprites for each strip definition.
// #
// # If a state's directions or frames aren't located sequentially
// # in the sprite sheet, you can define their strips separately
// # and they will be correctly combined.

Advertisement

Comments

DarkCampainger: (May 19 2013, 11:27 am)
Hey Akando5959,

I uploaded an image showing how the margins and spacing work:
http://www.byond.com/games/hubpic/102751_12878.png

The only strange thing is that the 'spacing' isn't applied around the outside edge of the image. I did that because it seemed easier for allowing sprite sheets that were offset a bit.

Let me know if you have any other questions!
Akando5959: (May 19 2013, 8:23 am)
How are you calculating the Margin and spacing on the skeleton.png. If I knew that I could get this to work a lot better. I have tried a few different things to figure out the spacing and Margins, but it still comes out with incorrect allignment.
Pyro_dragons: (Aug 14 2012, 4:50 pm)
Perhaps a quick alert before the file choice? To choose "Load Sprite Sheet" or "Load Files in Sequence". Something along those lines perhaps.
DarkCampainger: (Aug 13 2012, 3:59 pm)
That should be feasible. I'll have to think about how I want it to work... whether it should be specified in the script or just run from a different verb.
Pyro_dragons: (Aug 13 2012, 10:04 am)
This is kind of a stretch, but would it be possible to also have an option to load single files in sequence into an icon or icon state?

What I mean is when sprites are rendered as single frames in separate files, with the same file name and an incrementing number at the end of it. I have a couple different effects programs and one does it this way while the other does it as separate files. This would be handy for me, and others I would imagine.

Not sure how feasible it is though.