melanke / CascadeCanvas

A framework for canvas that follows the Javascript patterns you already know
6 stars 0 forks source link

Drawing tiles #23

Closed melanke closed 10 years ago

melanke commented 10 years ago

Define tile types and use them to draw a element

CC.tiles = {
    1: {
        url: "path/to/resource/loaded/before.png",
        x: 160, //x position of the sprite in the image
        y: 48, //y position of the sprite in the image
        frames: 5, //how many frames of the animation,
        delay: 10 //how many loops until the next frame
    }
};

CC("#elementId").eg(0).layers = {
    layername: {
        tileSize: { w: 16, h: 16 },
        tiles: [
            [ 2,       "a", "a", 1, 1, 1, 1, 2, "a" ],
            ["oh my!", "a", "a", 1, 1, 1, 1, 2, "a" ],
            ["oh my!", "a", "a", 1, 1, 2, 1, 2, "a" ],
            ["oh my!", "a", "a", 1, 1, 1, 1, 2, "a" ],
            ["oh my!", "a", "a", 1, 2, 1, 1, 2, "a" ],
        ]
    }
};