Description

Assigns an identifier to an area of the spritesheet. A grid can be defined to be faster.

Usage

Parameters

  • set {Object} optional

    : If the key is called grid, the image is cut from a grid. Set the grid with

    • size: [Line number, column number]
    • tile (optional) : [Width of the box, Height of the box]
    • set : Each identifier in array starting from the firt case in top left of the grid
    • reg : [Position X of origin point, Position Y of origin point]

    If the key is not "grid", we assign a zone identifier: [x, y, width, height, 0, regX (optional), regY (optional)] regX and regY are origin points

Example

: var spritesheet = canvas.Spritesheet.new("myspritesheet"); spritesheet.set({ grid: [{ size: [4, 5], tile: [107, 107], set: ["play", "playerhover", "zoomp", "zoomm"] }], btnplay: [433, 33, 215, 188] }); Here, there is a grid of rows and 5 columns of 107px width and height. The first box is called "play". We have another area placed at positions (433, 33), width is 215px and height is 188px. The ID of this area is "btnplay"

Discussion