Create your own sprite resource files Actor Editor - David Brebner (c) Unlimited Realities 97
I have no responsibility for anything you might do with this software. But feel free to do what you want.

This began as part of URGAT (Unlimitied Realities Graphical Authoring Tool). Due to lots of questions, and seeing I used it in my tutorials I figured I really ought to make it public. I had described it as a sprite editor - this is not really correct. It's actually an actor editor. I don't want to begin to develop graphical editor (well I do, but too many projects).

Whats it Do?

I use the Actor Editor for all sorts of projects. It is a tool for selecting and registering variable sized and positioned characters or cells from a bitmap.

To create the bmp or gif initially you can use paint shop, Photoshop, Fractal Design Painter, Photoimpact, 3DSMax... whatever you prefer. I often use images I scan or capture from video.

Explanation

For each cell in our actors sprite file (each picture) we need 6 numbers to descibe it.

  • Xpos and Ypos - the x and y offset the cell should be displayed at
  • X and Y - the position on the source bitmap of the top left hand corner of the cell
  • Width and Height - describe the size of the cell.
These six numbers will make life a LOT easier for you when displaying any kind of multi-frame graphics in your program. The data is really easy to retrieve too. The actor Editor creates a file of the same name as the image but with an SPR (for sprite) extension. This is simply a sequential list of integers which can be loaded using the following VB code.

'hold the sprites
 Private spnx%(15), spny%(15), spnw%(15)
 Private spnh%(15), spnox%(15), spnoy%(15)

'load up the sprites
Open App.Path & "\whack_img.spr" For Random As #1 Len = 2
For a% = 0 To 14
    Get #1, a% * 6 + 1, spnox%(a% + 1)
    Get #1, a% * 6 + 2, spnoy%(a% + 1)
    Get #1, a% * 6 + 3, spnx%(a% + 1)
    Get #1, a% * 6 + 4, spny%(a% + 1)
    Get #1, a% * 6 + 5, spnw%(a% + 1)
    Get #1, a% * 6 + 6, spnh%(a% + 1)
Next
Close #1

This system overcomes the tedious job of designing sprites on a grid. This was a traditional method known as tile sets. The idea was that a give cell was square in shape and it's position in the source image can be calculated by multiplying the width and height of the squares by the column and row.

There are two big disadvantages the Actor Editor overcomes. First you can use sprites of any size, second you can register your sprites easily. In a graphics program you cannot usually flip between cells. With the actor-editor just press the up and down keys to flip between cells, making sure the animation is smooth.

Instructions

First you choose a BMP or GIF you want to use as a source bitmap. The actor_editor wall automatically load an SPR file if one exists or create one if it does not.

Changes are save when you change image files. Infact To save you must change files rather than exiting by closing the application.

Actor Editor Screen shot

The application can be resized or maximised to make best use of your screen. The green line is a splitter bar. By positioning your mouse above it you can drag it to adjust the screen proportions.

Each row of the grid on the bottom left describes a cell in the sprite. You can navigate this grid and manually adjust cells with the keyboard.

I have provided keyboard and mouse shortcuts for manipulating the 6 magin numbers. You can adjust the current cell (row in the grid, picture..)

Mouse : By dragging the flashing selection in the source bitmap above with the mouse. You can drag the sides of the flashing rectangle to change its size. You can also drag the cell in the bottom right preview window to adjust its x,y offset.

Keyboard : Arrows and Ctrl adjust the top left corner of the selection (x and y). Arrows and Shift adjust the width and height of the selection. Alt and arrows move the x and y offsets.

The x,y offset can be seen here. The cats mouth cell is offset in the bottom right so it lines up with the first cell.

Testing an animation

You can test an animation by typing in the test sequenct text box at the bottom left. The sequence of frames should be seperated and followed by a comma. When you press the test button the animation button will loop until you press it again.

Registering against a Background

I often use a main image, which I then animate sections of. You can see the cat on the clipboard example in the screen shots I have included. The main graphic, and first cell is a cat sitting on a clipboard. The following cells are the cat looking around and moving its tail.

To make it easy to line the tail or eye animations up with the first cell I have added the Use as Bkg button. This will take the cell number you enter and use it as a background behind the current cell. Just press it again to remove the background.

Hope you all enjoy the Actor Editor.

Remember to look at the wackarat tutorial to find out how to load and use SPR files in your programs.

David Brebner
d.brebner@massey.ac.nz