About Bundles

SwinGame has bundles that allow you to load many resources at once. This will get you started making and using your own bundles.



Read these first

About Resources



Games often require a large number of resources. With different levels, characters, animations, music, and sound effects, it can be cumbersome to have to load each of these individually in your code. To help overcome this, SwinGame provides bundles.

Conceptually, a bundle is a collection of resources that can be loaded by SwinGame as a group. This is achieved by creating a bundle script that lists all of the resources that you want loaded, and then loading this bundle in your code by calling using the LoadResourceBundle or LoadResourceBundleNamed functions.

The bundle scripts are located in the Resources/bundles folder. Each script is a text file that contains the details of the resources to load. Each line of the file describes a single resource, with comma separated fields. The first field contains the type of resource to load being one of the following:

  • ANIM
  • to load an animation,
  • to load an image,
  • to load another bundle.
  • FONT
  • to load a font,
  • to load music,
  • to load panel for the GUI,
  • to load a sound effect, or
  • to create a timer.

Following the resource kind is the resources name, and the associated filename for the resource. The name is used to access the resource once the bundle is loaded, while the filename indicates which resource to load. You need to ensure that the names are unique for each resource otherwise some of the resources will not be accessible.

Bitmap and font resources also require additional information.

  • can optionally be followed by bitmap cell details useful for animation (see About Animation). This is in the format: BITMAP, name, filename, width, height, cellCols, cellRows, cellCount. Once the bitmap is loaded the bundle will set the cell details from the information given.
  • FONT
  • must be followed by the point size for the font.

Once you're done with a bundle you can release it from memory by calling ReleaseResourceBundle. This releases all the resources loaded in the bundle from memory.

The following is an example of a bundle, it includes the most common resource kinds you can import in SwinGame.

    BITMAP,myBitmapWithCells,image1_name.png, 500, 100, 10, 2, 19 

As you can see from the example bundles can load a variety of resources, including bundles themselves. Bitmaps can be loaded with cells and without cells.