Scrolling Game Development Kit UI Help  

Sprites and Paths

This dialog has many parts, so the help has been split into 4 parts:

The top of the dialog contains three lists. The list on the left displays all the paths in the project, the list in the middle displays the points in the currently selected path, and the list on the right displays all the sprites in the project. If these lists get unwieldy, an alternative method of selecting paths and sprites is to use the hierarchy in the main project window. When a path is selected, the first sprite that references that path is automatically selected in the sprite definition list on the right (unless the already-selected sprite references the selected path). When a sprite definition is selected, nothing is changed unless you click the "Load Sprite" button (otherwise it could be very inconvenient to update existing sprites). Once you load a sprite definition, the path it references is selected in the path list at the left.

When a path is selected you can see the map and layer to which it applies listed below. This map and layer are used to determine many aspects relating to the creation of a sprite (for instance, which map the sprite is added to when it is created, since sprites are saved in the MAP file).

Before continuing, it will be helpful to understand the differences between a sprite, a sprite definition and a sprite template.

Sprite
This is a particular instance of a graphic at a particular position in a particular layer in the map, moving at a particular velocity. It depends on its definition and template for information on where to move next. Sprites are not persistent objects in a standard project. The only time they are saved is when you use the save game special function (new in 1.4) while playing the game (then they get stored only in a special .SAV file). The project itself, however, never stores sprites themselves. They are created at their respective starting positions each time the map is loaded/initialized.
Sprite Definition
This links a sprite to a template, and adds specific information about which path to follow, whether to follow that path relative to the sprite's starting position, and whether an instance of the sprite should be automatically created with the map. There can be multiple sprites based on the same Sprite Definition. The Sprite Definition is saved with the map and contains all the information necessary to create a sprite instance. Sprite definitions are not changed in the process of playing a game -- they are static and persistent (unless altered by script code).
Sprite Template
The majority of the information about a sprite is defined here. Since there can be many sprites with similar attributes, it's efficient to separate this information off into a singular point of reference. The Sprite Template contains a reference to a Solidity Definition (indicating which tiles this type of sprite sees as solid), animation speed, state definition information (how many states, how many frames in each animated state, which tile in each animation frame), what rules control the movement of this type of sprite, movement speed, gravity, inertia, and a collision category defining what collisions sprites of this template are involved in. As of version 1.3, it also contains information that indicates whether sprites using the template should follow a specific class of sprites, whether to automatically delete the sprite when it is off screen, off map, or motionless, and what to do when it reaches the end of a path. There can be multiple Sprite Definitions associated with each Sprite Template.

In summary, a sprite template defines a type of sprite (Player, Platform, Slime Monster, Bouncy Ball); a sprite definition defines a place for a sprite based on a template (a platform that travels to the store, a Slime Monster that attacks the player at the entrance to this cave, a Bouncy Ball that follows these stairs); a sprite is a single runtime instance based on a definition (the first of two platforms that travel to the store, the Slime Monster that was created at the entrance to the cave after the first one was destroyed, the Bouncy Ball that happens to currently be bouncing off the player).

As far as the user interface is concerned, the three objects are separated like this: Sprite Templates are defined in the lower half of this dialog, Sprite Definitions are defined in the upper half of this dialog, and Sprites are created only at runtime and can only be accessed or affected through script, special functions or collision definitions.

The process of creating a sprite generally follows these steps:

Clicking "Update Sprite" will update the sprite definition selected in the "Sprite definitions" list and update the Sprite Template selected in the "Template" field, and associate the selected sprite with the selected template and path.

Delete sprite deletes the selected sprite definition from the map in which it resides. The other delete buttons are a bit more complicated. The "Delete Template" button will only delete the template if it's not being referenced by any sprite definitions. Likewise, the "Delete Path" button will only delete the path if it's not being referenced by any sprite definitions. These commands will display an error message if you attempt to delete something that's in use, and the selected item will not be deleted.

The "Offset Path" button is handy if you have defined your path with the center of the sprite in mind instead of the top left corner. If your sprite images are 32 pixels by 32 pixels, you can simply enter the value "-16" into the boxes next to "by:" and click the "Offset Path" button. This will move all the points in the path left 16 pixels and up 16 pixels. This could also be useful if the path was created with a different sized sprite in mind.

The "Delete Point" button can be used to delete individual points from the path. When "Delete Point" is clicked, the selected point will be deleted from the path. Do not attempt to use a path without any points, such a path should be deleted and re-created in the Map Editor with at least one point.

The "Insert Delay" button was added to version 1.4 with the introduction of delay points in paths. Selecting a point and clicking this button will prompt for a delay and then add a delay point after the selected point. This has the effect of causing the sprite to delay for the specified number of frames after reaching that point. Delay points are similar to other points and may be selected and deleted. Delay points can also be added in the map editor while creating a path by pressing the "P" key.

The "Load Sprite" button will select the sprite's path in the "Path" list, select the template referenced by the sprite in the "Template" field, and load all the other sprite and template parameters into the appropriate fields in both the top and bottom half of the dialog. The sprite and/or template can then be updated (with the update button) or copied (with the Create Sprite button). Whether a new template is created or simply updated is based solely on the name, not the button pressed. If the name of the template matches an existing template in the list, the existing template will always be updated; If the name of the template does not match any existing template in the list, a new template will always be created and the sprite will be associated with this new template. The old template will never be implicitly deleted (use "Delete Template" to delete an unused template) because it is always possible to create a new sprite that might want to reference that template.