-
Notifications
You must be signed in to change notification settings - Fork 0
Engine.Loader.API
Engine. Loader
Class for loading and storing resources. On engine startup a Loader object is instantiated to the global variable "loader". This loader object will also create a load overlay (the overlay saying "jsEngine loading"), this overlay will not be removed until the loader.hideOverlay() is called.
Constructor for the Loader class. This function will also create a load overlay which will not disappear until the hideOverlay is called. Therefore, remember to call hideOverlay, when your game is ready to be shown.
- Source:
-
Checks if all resources - of all themes - has been loaded. This check is automatically called any time a single resource has finished loading.
- Source:
Whether or not all themes' resources has been successfully loaded
- Type
- boolean
-
Generates a mask for an image specified by its resource string. This function is used by getMask to fetch and cache masks for each of the loaded images.
Name Type Description resourceString
string A resource string specifying the image to generate a mask for
alphaLimit
number An alpha value (0-255). Pixel having this alpha value or larger will become black on the mask, pixels with a value below the limit will become completely transparent
- Source:
A canvas element with the generated mask
- Type
- HTMLCanvasElement
-
Fetches all loaded music tracks' resource strings (from all themes).
- Source:
An array containing all loaded music tracks' resource strings
- Type
- string[]
-
Fetches all loaded sounds' resource strings (from all themes).
- Source:
An array containing all loaded sounds' resource strings
- Type
- string[]
-
Fetches an image from the Loader. This function will automatically be called by objects that implements the Sprite object.
Name Type Description resource
string The resource string of the image that should be fetched
themeName
string The name of the theme from which the image should be fetched. If unset, the engine's default theme will be used
- Source:
The image element corresponding to the resource string and theme
- Type
- HTMLImageElement
-
Fetches all loaded images' resource strings (from all themes).
- Source:
An array containing all loaded images' resource strings
- Type
- string[]
-
Creates (or loads from cache) a mask for an image which is loaded by the Loader. This function is automatically used by the Collidable object for fetching masks for collision checking.
Name Type Description resource
string The resource string of the image that should be fetched
themeName
string The name of the theme from which the image should be fetched. If unset, the engine's default theme will be used
- Source:
A generated mask (canvas element) for the image element corresponding to the resource string and theme
- Type
- HTMLCanvasElement
-
getMusic(resource, themeName) → {Sound.Music}
-
Fetches a music track from the Loader.
Name Type Description resource
string The resource string of the track that should be fetched
themeName
string The name of the theme from which the track should be fetched. If unset, the engine's default theme will be used
- Source:
A Music object corresponding to the resource string and theme
- Type
- Sound.Music
-
Fetches a resource from the Loader's cache. Used by the getImage-, getSound- and getMusic functions.
Name Type Description resource
string The resource string of the resource that should be fetched
typeString
string A string representing the resource type, possible values are: "image", "sfx" and "music"
themeName
string The name of the theme from which the image should be fetched. If unset, the engine's default theme will be used
- Source:
The resource corresponding to the provided resource string, resource type and theme name
- Type
- HTMLImageElement | Sound | Music
-
getSound(resource, themeName) → {Sound.Effect}
-
Fetches a sound from the Loader.
Name Type Description resource
string The resource string of the sound that should be fetched
themeName
string The name of the theme from which the sound should be fetched. If unset, the engine's default theme will be used
- Source:
A Sound object corresponding to the resource string and theme
- Type
- Sound.Effect
-
Fades out the load overlay (which is automatically created by Loader's constructor). Remember to call this function, when your game is ready to be shown. Otherwise, the load overlay will never disappear.
Name Type Description callback
function A callback function to run when the overlay has finished fading out
- Source:
-
Loads JavaScript classes from files. The loaded classes' names must follow the following format: [ClassName].js
Name Type Description paths
string[] An array of paths to JavaScripts - containing classes - which should be loaded
- Source:
True, when the classes has been loaded without any errors
- Type
- boolean
-
Loads an external resource to the built in External-theme
Name Type Argument Default Description resourceString
string The proposed resource string of the resource when loaded
path
string The path to the resource's file
typeString
string <optional>
"images" A string defining the type of resource, can be: "images" (image file), sfx (sound effects) or "music" (background music)
onLoaded
function <optional>
function () {} A function to call when the resource has been loaded
options
string <optional>
"" A string defining the resource options (same as the string used for defining animations in a theme file)
- Source:
-
Loads resources to a theme. This function is used by loadThemes for caching the theme resources.
Name Type Description theme
Object A theme object to load the resources to
object
Object An object containing references to theme resources (like the subcategories of theme files)
typeString
string A string defining the resource type. Supported types are: "images", "sfx" and "music"
- Source:
-
Loads a list of themes. This function is automatically called by the Engine during its startup, for loading the themes specified by the launch options.
Name Type Description themeNames
string[] An array of theme names (as strings) to load
callback
function A callback function to run when all the themes has been loaded
- Source:
-
Reloads all classes. This function is very useful for applying code changes without having to refresh the browser, usually it has to be run multiple times though, to force the browser not to just load the files from its cache.
- Source:
Generated with wicked.
- Engine.Camera
- Engine.CustomLoop
- Engine.Loader
- Engine.Room
- Engine
- Input.Keyboard
- Input.Pointer
- Math.Circle
- Math.Line
- Math.Polygon
- Math.Rectangle
- Math.Vector
- Sound.Effect
- Sound.Music
- View.Child
- View.Circle
- View.Collidable
- View.Container
- View.GameObject
- View.Line
- View.Polygon
- View.Rectangle
- View.Sprite
- View.TextBlock
- global