Description

Resource management game. The class is used with the properties "materials" in the scene but you can still use it for loading external resources to the scene

Example

Using Sound :

var canvas = CE.defines("canvas_id").
    ready(function() {
        canvas.Scene.call("MyScene");
    });

canvas.Scene.new({
    name: "MyScene",
    ready: function(stage) {
        canvas.Materials.load("images", [
            {img1: "path/to/img1.png"},
            {img2: "path/to/im2.png"}
        ], function(img) {
            console.log("Image is loaded");
        }, function() {
            console.log("All images are loaded");
        });
    }
});

Methods

get

Get the picture or sound according to its identifier

imageToCanvas

Converts an image (Image) in Canvas. The returned object is : { canvas: {HTML5CanvasElement}, ctx: {Context2d} }

transparentColor

Make a color transparent in the image

invertColor

Inverts the colors of the image

cropImage

Can crop an image to use independently. Useful for creating patterns in HTML5

opaqueImage

Makes transparent pixels (> 0 and < 255) opaque

getExtension

Gets the file extension

getBasePath

Retrieves the base of a path

getFilename

Gets the file name with or without the extension in a path

load

Load a resource

Discussion