Zinggi/elm-game-resources/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Game.Resources

A module for managing resources needed for games. This currently only manages textures, but a future version might add sounds, 3d-meshes etc..

Resources

The main type of this library

init : Resources
update : Msg -> Resources -> Resources
type Msg

Textures

type alias Texture =
Texture
loadTextures : List String -> Cmd Msg

Loads a list of textures from the given urls. PNGs and JPEGs are known to work. For WebGL make sure that your textures have a dimension with a power of two, e.g. 2^n x 2^m

getTexture : String -> Resources -> Maybe Texture

Returns a maybe as the texture might not be loaded yet.

loadTexturesWithConfig : LoadTextureConfig msg -> List ( TextureFilter, String ) -> Cmd msg

Same as loadTextures, but gives you more controll by being able to react to a texture loading error and by specifying a texture filter.

loadTexturesWithConfig
    { success = Resources
    , failed = LoadingTextureFailed
    }
    [ (linear, "images/blob.png"), (nearest, "images/box.jpeg") ]
type alias LoadTextureConfig msg =
{ success : Msg -> msg
, failed : String -> msg
}
type alias TextureFilter =
TextureFilter
linear : TextureFilter
nearest : TextureFilter
textureSize : Texture -> ( Int, Int )