Resources

Resources

Description

Supports the loading and releasing of game resources and bundles, including application path settings. Current resource types include images, sounds, music and animation files to name a few. Resource files must be saved in specific locations of the Resources folder for your game.

App Path

Returns the application path set within SwinGame. This is the path used to determine the location of the game's resources.

  • App Path () : String [show]

    Returns the application path set within SwinGame. This is the path used to determine the location of the game's resources.

    Returns:
    String :
    Signatures by Language:
    C/C++: void app_path(char *result);
    Pascal: function AppPath(): String;

Filename To Resource

Returns the path to the file with the passed in name for a given resource kind. This checks if the path exists, throwing an exception if the file does not exist in the expected locations.

  • Filename To Resource (name, kind) : String [show]

    Returns the path to the file with the passed in name for a given resource kind. This checks if the path exists, throwing an exception if the file does not exist in the expected locations.

    Parameters:
    name : String
    kind : ResourceKind
    Returns:
    String :
    Signatures by Language:
    C/C++: void filename_to_resource(const char *name, resource_kind kind, char *result);
    Pascal: function FilenameToResource(name: String; kind: ResourceKind): String;

Has Resource Bundle

Returns true if the resource bundle is loaded.

  • Has Resource Bundle (name) : Boolean [show]

    Returns true if the resource bundle is loaded.

    Parameters:
    name : String
    Returns:
    Boolean :
    Signatures by Language:
    C/C++: bool has_resource_bundle(const char *name);
    Pascal: function HasResourceBundle(name: String): Boolean;

Load Resource Bundle

Load a resource bundle showing load progress.

  • Load Resource Bundle (name) [show]

    Load a resource bundle showing load progress.

    Parameters:
    name : String
    Signatures by Language:
    C/C++: void load_resource_bundle_with_progress(const char *name);
    C++: void load_resource_bundle(const char *name);
    Pascal: procedure LoadResourceBundle(name: String);
  • Load Resource Bundle (name, showProgress) [show]

    Load a resource bundle showing load progress.

    Parameters:
    name : String
    showProgress : Boolean
    Signatures by Language:
    C/C++: void load_resource_bundle(const char *name, bool showProgress);
    Pascal: procedure LoadResourceBundle(name: String; showProgress: Boolean);

Load Resource Bundle Named

Load a resource bundle mapping it to a given name, showing progress.

  • Load Resource Bundle Named (name, filename, showProgress) [show]

    Load a resource bundle mapping it to a given name, showing progress.

    Parameters:
    name : String
    filename : String
    showProgress : Boolean
    Signatures by Language:
    C/C++: void load_resource_bundle_named(const char *name, const char *filename, bool showProgress);
    Pascal: procedure LoadResourceBundleNamed(name: String; filename: String; showProgress: Boolean);

Path To Resource

Returns the path to the filename within the game's resources folder.

  • Path To Resource (filename) : String [show]

    Returns the path to the filename within the game's resources folder.

    Parameters:
    filename : String
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_other_resource(const char *filename, char *result);
    C++: void path_to_resource(const char *filename, char *result);
    Pascal: function PathToResource(filename: String): String;
  • Path To Resource (filename, kind) : String [show]

    Returns the path to the filename for a given file resource.

    Parameters:
    filename : String
    kind : ResourceKind
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_resource(const char *filename, resource_kind kind, char *result);
    Pascal: function PathToResource(filename: String; kind: ResourceKind): String;
  • Path To Resource (filename, subdir) : String [show]

    Returns the path to the filename that exists within the game's resources folder in the indicated sub directory. For example, to get the "level1.txt" file from the Resources/levels folder you call this passing in "level1.txt" as the filename and "levels" as the subdir.

    Parameters:
    filename : String
    subdir : String
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_resourse_in_subdir(const char *filename, const char *subdir, char *result);
    C++: void path_to_resource(const char *filename, const char *subdir, char *result);
    Pascal: function PathToResource(filename: String; subdir: String): String;
  • Path To Resource (filename, kind, const subPaths) : String [show]

    Returns the path to a resource given its filename, kind, and any subPaths. For example: to load the image bullet01.png from the bullets subdirectory you pass in bullet01.png as the filename, ImageResource as the kind, and bullets as the subPaths. This will then return the full path to the resource according to the platform in question.

    For example: .../Resources/images/bullets/bullet01.png

    Parameters:
    filename : String
    kind : ResourceKind
    subPaths : StringArray
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_resource_with_sub_paths(const char *filename, resource_kind kind, const string_array subPaths, char *result, int32_t subPaths_len);
    C++: void path_to_resource(const char *filename, resource_kind kind, const string_array subPaths, char *result, int32_t subPaths_len);
    Pascal: function PathToResource(filename: String; kind: ResourceKind; const subPaths: StringArray): String;
  • Path To Resource (filename, kind, subdir) : String [show]

    Returns the path to the filename that exists within the game's resources folder in the indicated sub directory of the directory for the given resource kind . For example, to get the "background.png" file from "level1" folder in the images folder (i.e. Resources/images/level1/background.png) you call this passing in background.png as the filename ImageResource as the kind and level1 as the subdir.

    Parameters:
    filename : String
    kind : ResourceKind
    subdir : String
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_resourse_kind_in_subdir(const char *filename, resource_kind kind, const char *subdir, char *result);
    C++: void path_to_resource(const char *filename, resource_kind kind, const char *subdir, char *result);
    Pascal: function PathToResource(filename: String; kind: ResourceKind; subdir: String): String;

Path To Resource With Base

Returns the path to a resource based on a base path and a the resource kind.

  • Path To Resource With Base (path, filename) : String [show]

    Returns the path to a resource based on a base path and a the resource kind.

    Parameters:
    path : String
    filename : String
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_other_resource_with_base(const char *path, const char *filename, char *result);
    C++: void path_to_resource_with_base(const char *path, const char *filename, char *result);
    Pascal: function PathToResourceWithBase(path: String; filename: String): String;
  • Path To Resource With Base (path, filename, kind) : String [show]

    Returns the path to a resource based on a base path and a the resource kind.

    Parameters:
    path : String
    filename : String
    kind : ResourceKind
    Returns:
    String :
    Signatures by Language:
    C/C++: void path_to_resource_with_base(const char *path, const char *filename, resource_kind kind, char *result);
    Pascal: function PathToResourceWithBase(path: String; filename: String; kind: ResourceKind): String;

Register Free Notifier

Using this procedure you can register a callback that is executed each time a resource is freed. This is called by different versions of SwinGame to keep track of resources and should not be called by user code.

  • Register Free Notifier (fn) [show]

    Using this procedure you can register a callback that is executed each time a resource is freed. This is called by different versions of SwinGame to keep track of resources and should not be called by user code.

    Parameters:
    fn : FreeNotifier
    Signatures by Language:
    C/C++: void register_free_notifier(free_notifier fn);
    Pascal: procedure RegisterFreeNotifier(fn: FreeNotifier);

Release All Resources

Release all of the resources loaded by SwinGame.

  • Release All Resources () [show]

    Release all of the resources loaded by SwinGame.


Release Resource Bundle

Release the resource bundle with the given name.

  • Release Resource Bundle (name) [show]

    Release the resource bundle with the given name.

    Parameters:
    name : String
    Signatures by Language:
    C/C++: void release_resource_bundle(const char *name);
    Pascal: procedure ReleaseResourceBundle(name: String);

Set App Path

Sets the path to the executable. This path is used for locating game resources.

  • Set App Path (path) [show]

    Sets the path to the executable. This path is used for locating game resources.

    Parameters:
    path : String
    Signatures by Language:
    C/C++: void set_app_path(const char *path);
    Pascal: procedure SetAppPath(path: String);
  • Set App Path (path, withExe) [show]

    Sets the path to the executable. This path is used for locating game resources.

    Parameters:
    path : String
    withExe : Boolean
    Signatures by Language:
    C/C++: void set_app_path_with_exe(const char *path, bool withExe);
    C++: void set_app_path(const char *path, bool withExe);
    Pascal: procedure SetAppPath(path: String; withExe: Boolean);