Crate gate_build [] [src]

Gate-Build contains utilities for packing image atlases and other assets as part of the build script for a Gate application (see the "gate" crate).

The AssetPacker of Gate-Build should be invoked in a build script in a Gate application. Rust enums are generated to reference the packed assets.

Example build script

In the below example, the user should place sprite png files in the "sprites" directory, tile png files in the "tiles" directory, music ogg files in the "music" directory, and sound ogg files in the "sounds" directory.

extern crate gate_build;

use std::path::Path;
use std::env;
use gate_build::AssetPacker;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let gen_code_path = Path::new(&out_dir).join("asset_id.rs");

    let mut packer = AssetPacker::new(Path::new("assets"));
    packer.cargo_rerun_if_changed();
    packer.sprites(Path::new("sprites"));
    packer.tiles(Path::new("tiles"));
    packer.music(Path::new("music"));
    packer.sounds(Path::new("sounds"));
    packer.gen_asset_id_code(&gen_code_path);
}

Structs

AssetPacker

Packs image atlases and other assets as part of the build script for a Gate application.